问题描述
我是编程新手,如果问题很愚蠢,请见谅。 我正在使用 Angular Emojis,我使用属性绑定显示带有变量的特定表情符号。
模板:
<angular-emojis [name]="emojivar" size="30" (mouseenter)="changeRoutine()" > </angular-emojis>
打字稿代码:
emojivar = 'taco';
changeRoutine(){
console.log(this.emojivar);
this.emojivar = 'tomato';
console.log(this.emojivar);
}
变量改变了,但表情符号没有改变。 有什么办法可以修复它,让它刷新吗?
解决方法
老实说,我看不出这行不通的任何理由。您可以尝试强制更改检测:
consturctor(private cdr: ChangeDetectorRef) {}
changeRoutine(){
console.log(this.emojivar);
this.emojivar = 'tomato';
console.log(this.emojivar);
this.cdr.detectChanges();
}
[编辑] 我查看了您正在使用的库,并且...它根本不处理更改: