我正在尝试在布尔值上使用 ngif 显示元素,如下所示:
<li *ngIf="!include == true">
<span class="badge badge-pill badge-danger">
<i [ngClass]="hearthClass"></i>
</span>
</li>
Run Code Online (Sandbox Code Playgroud)
我的 include var il 初始化为 false 并像这样切换状态:
this.localStorageService.getCurrentUser().then((res) => {
this.userProfile = res;
if(this.song.likes.includes(this.userProfile._id)){
this.include = true
}
this.classHeart();
});
Run Code Online (Sandbox Code Playgroud)
谢谢大家 !