Angular2 ngModel inside of ngFor

前端 未结 3 1399
借酒劲吻你
借酒劲吻你 2020-12-09 05:49

I am trying to bind an array of strings from my inputs, so in the html file I wrote this:

3条回答
  •  情歌与酒
    2020-12-09 06:22

    The problem is with using an array of primitive values (words) in ngFor.

    You can change words to an array of objects like

    words = [{value: 'word1'}, {value: 'word2'}, {value: 'word3'}];
    

    and use it like

      

    This might also be solvable using trackBy but I'm not sure.

提交回复
热议问题