【发布时间】:2017-11-22 19:57:53
【问题描述】:
我正在使用 Angular 开发应用程序。
我会显示来自通知数组的通知。它们来自套接字连接。
<div class="notifications-container">
<div *ngFor='let notification of notifications'>
<div class="notification-messege" title="{{notification.body.content}}">
{{notification.body.content}}
</div>
</div>
</div>
如果通知超过 5 个,我该如何隐藏?
【问题讨论】:
-
要隐藏
notification-messege吗? -
下面的一些答案显示了使用 *ngIf 的解决方案。如果是我,我会创建一个仅包含 5 个项目的第二个过滤数组。然后我将我的模板绑定到那个过滤后的数组。
-
notifications | slice: 0: 5
标签: html angular typescript dom socket.io