2017-07-19 13 views
0

私はウェブ開発に新しいです、私が解決しようとしている問題は、非常に基本的なものですが、私は解決策が見つけられなかったためにたくさん検索しました。 私は以下の2つのWebページonetwo角度2の投稿データを読む

を持っていることは、この上のフォームは、自動的に次のウェブページtwo.htmlに掲示し、以下ComponentOne

で書かれているそのためのコードであります 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> 

です

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でどのように読むのですか?要件は、この場合はServiceを使用してください。全く問題はありません。 サービスクラスなしでこれをどのように達成できますか?

答えて

0

このイベントに外部からアクセスするには、おそらくEventEmitterと@Outputを使用する必要があります。その後、別のhtmlファイルでイベントとして使用し、変数をtypescriptファイルに$ eventとして渡します。

私はあなたの質問を正しく得て、あなたを誤解していないことを願っています。

関連する問題