【发布时间】:2018-12-01 17:43:15
【问题描述】:
在这种情况下,仅当 id 为 1 时,我才需要在 ngfor 中显示列表的一部分。 我怎样才能做到这一点?
while id==1
*ngFor="let item of list">{{item.value}}
this.list = [
{id:1, value:1},
{id:1, value:2},
{id:1, value:3},
{id:2, value:4},
{id:2, value:5},
{id:2, value:6}
];
【问题讨论】:
-
this.filteredList = this.list.filter(e => e.id === 1);,现在你使用 ngFor 来显示过滤列表的每个元素 -
请添加您已经尝试过的任何代码/方法。