【发布时间】:2019-07-17 08:54:32
【问题描述】:
我的通知变量有一个动态数字计数。
如果小于 99,我使用三元运算符显示该数字,否则,我想显示“99+”。
我试过这个:
<div class="notification-badge" *ngIf="unreadNotificationsCount > 0">
{{(unreadNotificationsCount < 99) ? {{unreadNotificationsCount}} : '99+'}}
..但它不允许在三元内进行字符串插值
【问题讨论】:
-
{{(unreadNotificationsCount
-
@ritaj 您需要双括号将数据绑定到 html。您的解决方案不会被绑定/渲染,它只是一个字符串/文本。
标签: angular conditional-operator string-interpolation