0
formbuilderを使用して物理ページに 'product.name'を列挙するにはどうすればよいですか?これは、入力フィールドの正常に動作しますが、私は最初のTDで物理の言葉を書きたい:ここフォームビルダーを取得して、入力フィールドだけでなく、product.nameを書き出すこともできます。
<table class="editPackagesGeneralTable" formArrayName="products">
<tr><th class="first">Product/Gift</th><th>Description</th><th>Cost</th><th class="last">Quantity</th></tr>
<tbody>
<tr *ngFor="let product of myForm.controls.products.controls; let i=index" [formGroupName]="i"><td>{{product.name}}</td><td>{{product.description}}</td><td>{{product.unitCost}}</td><td><input type="hidden" formControlName="id" /><input type="text" formControlName="name" /></td></tr>
</tbody>
</table>
は私のtypescriptですです:
this.myForm = this.fBuilder.group({
products: this.fBuilder.array([])
});
this.httpService.getExtrasList()
.subscribe((res) => {
this.items = res.json();
console.log(res.json());
this.items.forEach(element => {
(<FormArray>this.myForm.get('products')).push(this.fBuilder.group({
id: [element.id],
name: [element.name]
}));
});
});
私はタイプスクリプトを含むように私の質問を改めました。テンプレートを変更するにはどうすればいいですか? –
ああ申し訳ありませんが、私はそれを取得していません。この答えは無関係です。 '{{product.name.value}}'は動作するはずです。それは? – n00dl3
ああ私はそれを試みたが、 "未定義のプロパティ '値'を読み取ることができませんエラーが発生しました。 これまでに多くのご協力ありがとうございました:) –