更新了 HTMLTextAreaElement 值属性,但 ngModel 未更新。
我注意到有一个角度的 ng 模型选项。
我需要在 ngModel 更新的选项中指定什么?
target: HTMLTextAreaElement = null;
appendToTarget(specialCharacters: UnicodeCharacter) {
this.target.value = this.target.value.concat(specialCharacters);
}
也许 angular 不知道值的变化,请尝试 $apply(( 或以角度样式执行此操作。
角度 2+
target: HTMLTextAreaElement = null;
constructor(private cdr: ChangeDetectorRef){}
appendToTarget(specialCharacters: UnicodeCharacter) {
this.target.value = this.target.value.concat(specialCharacters);
this.cdr.markForCheck();
this.cdr.detectChanges();
}