角度2 对数组显示信息内的项目进行计数



在这里,我又有以下组件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>

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

就像 awiseman 提到的那样,它应该是

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

相关内容

  • 没有找到相关文章

最新更新