我有2种方式的绑定模型,我在页面加载时将其分配给temp变量。但是temp变量也会改变NgModel。
this.questionService.getAll(this.id, this.bcID).subscribe(_result => {
this.questions = _result.data.filter(x => x.isDeleted === false);
this.tempQuestions = _result.data.filter(x => x.isDeleted === false);
});
使用KEndo UI网格
<kendo-grid [data]="gridView"
[height]="550"
[skip]="gridState.skip"
(edit)="editHandler($event)"">
this.gridView = process(this.questions, this.gridState);
答案 0 :(得分:0)
基本上,变量this.questions
和this.tempQuestions
都指向相同的对象。为确保更改不会反映到this.tempQuestions
,请对this.questions
对象进行深层克隆。
这会有所帮助
this.questionService.getAll(this.id, this.bcID).subscribe(_result => {
this.questions = _result.data.filter(x => x.isDeleted === false);
this.tempQuestions = JSON.parse(JSON.stringify(this.questions));
});