如果组件方法生成输出事件,则 Angular 组件变量不会在视图中更新。焦点变量是'qMode',
生成输出事件的函数(不更新变量)
save() {
if (this.questionForm.valid) {
this.question.type = this.questionForm.value.type;
this.question.description = this.questionForm.value.description;
this.qMode = 'view';
this.saveQuestion.emit({
index: this.index,
question: this.questionForm.value,
});
}
}
不生成输出事件的函数(更新变量)
save() {
if (this.questionForm.valid) {
this.question.type = this.questionForm.value.type;
this.question.description = this.questionForm.value.description;
this.qMode = 'view';
}
}
请在这里找到代码演示,