我在我的应用程序中使用mat-card并通过ngFor渲染它。因此计算卡的内容,但是来自此计算的值根本不会呈现。
我尝试在卡片中做一些常规输出,它工作正常,当我需要使用花括号时,它会中断。键入类似{{'渲染此字符串'}}的内容也不起作用。
<mat-card class="tribe-card" *ngFor="let committee of (committeesList$ | async)">
<mat-card-header>
<!-- This is not working -->
<mat-card-subtitle><p>{{'committee.sName'}}</p></mat-card-subtitle>
<!-- This is working -->
<mat-card-title><p>Absolutely regular rendering</p></mat-card-title>
</mat-card-header>
<!-- This is not working -->
<mat-card-content>{{committee.oActivePhase.sName}}</mat-card-content>
</mat-card>
什么可能是这个错误的来源,我该如何解决这个问题?
删除单引号:{{committee.sName}}
还有一件事:使用Elvis运算符,因此null / undefined属性会导致无法恢复的错误:
{{committee?.oActivePhase?.sName}}