* ngFor条件,其中item.id === group.id

时间:2018-02-07 05:01:44

标签: angular

我必须制作一些嵌套列,其中每列都有一个group.id,我需要放置具有匹配ID的项目,如何使用ngFor进行此操作?

所以例如我有一个像这样的对象:

columnNames = [
    {id: 0, name: 'Opened'},
    {id: 1, name: 'Responded'},
    {id: 2, name: 'Material requested'},
    {id: 3, name: 'Material sent'},
    {id: 4, name: 'Interview requested'},
    {id: 5, name: 'Interview completed'},
    {id: 6, name: 'Follow up sent'},
    {id: 7, name: 'Follow up responded'},
    {id: 8, name: 'Article secured'},
    {id: 9, name: 'Article published'},
    {id: 10, name: 'Not interested'}
];

然后是这样的项目:

{
    "contactId": 0,
    "contactName": "John Doe",
    "mediaOutletName": "Gadget",
    "pitchingInitiativeId": 0,
    "statusHistory": [
        {
            "completedDate": "2018-02-07T03:45:19.811Z",
            "storyFunnelId": 0,
            "storyFunnelStatusId": 0
        }
    ],
    "storyFunnelId": 0,
    "storyFunnelStatusId": 0,
    "updatedDate": "2018-02-07T03:45:19.811Z",
    "userId": 0
}
我的模板中的

需要嵌套在storyFunnelStatusId = column.id

的每一列中

在我的模板中是这样的:

<div class="board-column" *ngFor="let column of columnNames">
    <div class="board-heading">
        {{ column.name }}
        <span class="count">4</span>
    </div>
    <div id="column-{{ column.id }}" class="card-body">
        <div *ngFor=""></div>
    </div>
</div>

1 个答案:

答案 0 :(得分:1)

你可以这样做,

<div id="column-{{ column.id }}" *ngIf="storyFunnelStatusId === column.id" class="card-body">

</div>