数组内的Angular2 Count项显示信息

时间:2016-05-24 00:56:33

标签: angular angular2-components

在这里,我有以下组件MyStoreComponent

 export class MyStoreComponent {
    stores: any[] = [{
        storeId: "456392",
        location: "New York",
        people: [{
            manager: "John",
            sales: "Claudia",
            tech: "Marcel"
        }, {
            manager: "Martin",
            sales: "Jenn",
            tech: "Oliver"
        }]
        }, {
        storeId: "456393",
        location: "California",
        people: [{
            manager: "Kim",
            sales: "Nancy",
            tech: "Marie"
        }]
    }];

 }

现在我想要计算每个分支内部的人员。例如456392有两个经理或456393只有一个

我尝试了

 <ul *ngFor="#store of stores">
    <li *ngFor="#person of store.people">
        <span *ngIf="person.length > 1">Show this</span>
    </li>
 </ul>

但我在某些方面输了,有什么帮助吗?请?

1 个答案:

答案 0 :(得分:5)

像awiseman提到的应该是

<ul *ngFor="#store of stores">
    <li *ngFor="#person of store.people">
        <span *ngIf="store.people.length > 1">Show this</span>
    </li>
 </ul>