ng-reflect-model shows correct value but not reflecting in input

前端 未结 3 1129
没有蜡笔的小新
没有蜡笔的小新 2021-02-04 06:16

Encountered a very weird issue where my application misbehaves in a very specific user case. I have a portal where users can add questions and answers and then edit them. In thi

3条回答
  •  逝去的感伤
    2021-02-04 06:51

    Apparently the issue was being caused because Angular wasn't able to track the elements of my array properly. I found this out very hard way. So just adding a trackBy attribute to my ngFor, I was able to resolve this.

    Added this to my component:

    customTrackBy(index: number, obj: any): any {
      return index;
    }
    

    and then in the template:

    So basically I am asking angular to track my elements in the array by index. It resolved the issue.

    Here assessment is the model for each of the question-answer set.

提交回复
热议问题