How to “walk” inside two arrays using the same *ngFor?

后端 未结 3 1481
北荒
北荒 2020-12-22 07:29

Basically I have two arrays, and I would like to store their values at the same time using a *ngFor, I did something like this just to show what I would expect:

3条回答
  •  -上瘾入骨i
    2020-12-22 08:10

    I think your issue is here:

    addAlternativeField() {
            this.alternativeFields.push(this.fbuilder.control(''));
            this.alternativeFieldsValues.push(this.fbuilder.control(''));
          }
    

    You are patching the arrays in direct reference to this. Isn't it supposed to be

    this.form.get('alternativeFields').push(this.fbuilder.control(''))
    

    Or do you have an additional getter?

提交回复
热议问题