Angular component variable is not updating in the view if the component method generates an output event. Variable in focus is 'qMode',
Function with generating output event (NOT UPDATING VARIABLE)
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,
});
}
}
Function without generating output event (UPDATING VARIABLE)
save() {
if (this.questionForm.valid) {
this.question.type = this.questionForm.value.type;
this.question.description = this.questionForm.value.description;
this.qMode = 'view';
}
}
Please find here Code Demo,