私は2つのコンポーネントがあります。parentComponentにとChildComponent:フォームのフォーム。フォームコントロールの継承ができますか?
parent.component.ts
<form #form="ngForm" (ngSubmit)="onSubmit(form)" novalidate>
<input type="text" name="firstControl" [(ngModel)]="firstControl" />
<input type="text" name="secondControl" [(ngModel)]="secondControl" />
<child-component>
</form>
{{form.value | json}}
child.component.ts今
<input type="text" name="thirdControl" [(ngModel)]="thirdControl" />
<input type="text" name="fourthControl" [(ngModel)]="fourthControl" />
、{{form.value | json}}
戻り{ "firstControl": "", "secondControl": "" }
、それはだが明らかです。私の質問は:子コンポーネントからフォームコントロールを継承する方法はありますか? ParentComponentの{ "firstControl": "", "secondControl": "", "thirdControl": "", "fourthControl": "" }
を取得する正しい方法は何ですか?出来ますか?
どのような素晴らしい投稿です! – Vega
完璧な説明。ありがとう、おいおい。 –