<div *ngFor="let bellNotification of earlierBellNotifications">
<mat-checkbox (change)="updateNotificationEventStatus(bellNotification.key, $event)"
[(ngModel)]="bellNotification.status==='READ'" (click)="$event.stopPropagation()" class="md-18">
<span class="wd-notification-event-checkbox" i18n>MARK AS READ</span>
</mat-checkbox>
</div>
尝试加载页面时,出现以下错误:
未捕获错误:模板分析错误:分析器错误:意外令牌 [bellNotification.status==='READ'=$event] 第 33 列的"=" ng:///AppSharedModule/BellNotificationComponent.html@43:12 (">
][(ngModel(]="bellNotification.status==='READ'" (click(="$event.stopPropagation((" class="md-18"> "(:ng:///AppSharedModule/BellNotificationComponent.html@43:12
我尝试用打字稿中的函数替换它,但我仍然收到类似的错误。
我尝试用打字稿中的值替换它,它有效,但它无法动态更新,因为它仅来自 ts 并且不依赖于 for 循环迭代器。
有人可以帮我指出我使用的语法中的错误吗?
我是Angular的新手。非常感谢参考链接。
表达式中的条件绑定[(ngModel)]
不起作用(我从来没有这样使用过(!
您可以使用[checked]
属性来check/uncheck
复选框,条件如下:
<div *ngFor="let bellNotification of earlierBellNotifications">
<mat-checkbox (change)="updateNotificationEventStatus(bellNotification.key, $event)"
///
[checked]="bellNotification.status === 'READ'" (click)="$event.stopPropagation()" class="md-18">
<span class="wd-notification-event-checkbox" i18n>MARK AS READ</span>
</mat-checkbox>
</div>
Working_Demo