我有一个 @Input 在它为真时做某事 ngOnChange 没有检测到它何时为假
@Input() viewMode: boolean;
ngOnChanges(changes: SimpleChanges) {
if (changes.viewMode.currentValue !== undefined) {
if (changes.viewMode.currentValue ) {
this.populateForm(this._event);
}else{
this.doSomething()
}
}
}
setValue(){
this.viewMode = false;
}
当我调用 setValue 函数时,它不属于 ngOnChange