2017-07-19 39 views
0

我是網絡開發新手也許我想解決的問題是一個非常基本的問題,但我已經搜索了很多解決方案無法找到一個。 我有兩個網頁onetwo在角度閱讀文章數據2

下面是one.html

<form id="requestForm" #requestForm ngNoForm action="{{requestUrl}}" method="POST"> 
<div *ngIf="requestmodel"> 
    <button class="btn-flat waves-effect waves-light transparent regNrmS2BN" type="submit" id="submitForm" style="color: transparent; background-color: transparent;">Pay</button> 
    <input type="hidden" name="name" [ngModel]="requestmodel.name" /> 
</div> 
</form> 

這上面的表格就會自動發佈到下一個網頁two.html以下是這是寫在ComponentOne

該代碼
ngOnInit(): void { 
    this.requestmodel = this.requestService.getRequest(); 
    this.requestUrl = 'http://localhost:3000/two'; 
    this.submitMe(); 
} 

submitMe() { 
    let me = this; 
    if ($('#submitForm') && $('#submitForm')[0]) 
     $('#submitForm')[0].click(); 
    else 
     setTimeout(function() { me.submitMe(); }, 100); 
} 

的問題是我怎麼在ComponentTwo讀取表格數據和要求是我不應該t使用Service,否則根本沒有任何問題。 那麼,如何在沒有服務級別的情況下完成此任務?

回答

0

您可能不得不使用EventEmitter和@Output來訪問此事件。然後在另一個html文件中作爲事件使用它,並將變量作爲$ event傳遞給您的打字稿文件。

我希望我把你的問題對,並沒有誤導你