我有这个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)可能是最好的选择 –