我有這個Angular2結合動態文本框
<ul>
<li *ngFor="let data of list">
//here bind a textbox to the id and get its value so something like
<input type="text" /> //am stuck
</li>
export class App {
textboxvalues:any[] = [];
list= [{
id: 1,
value: 'One'
},
{
id: 2,
value: 'Two'
}];
}
我怎樣才能在價值和文本框的ID綁定,這樣當我收集的
console.log(textboxvalue)
值它提供{id,值}例如
{1:"textbox1", 2:"textbox2"}
甚至爲對象
{1, "textbox1"}, {2, "textbox2"}
[FormArray](https://angular.io/guide/reactive-forms#use-formarray-to-present-an-array-of-formgroups)[反應性表格](HTTPS的:// angular.io/guide/reactive-forms#reactive-forms)可能是最好的選擇 –