Angular2 计数数组内的项目显示信息
Angular2 Count items inside of the array display information
在这里,我有以下组件 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>
但我在某些方面输了,有什么帮助吗?请问?
像智者说的应该是
<ul *ngFor="#store of stores">
<li *ngFor="#person of store.people">
<span *ngIf="store.people.length > 1">Show this</span>
</li>
</ul>
在这里,我有以下组件 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>
但我在某些方面输了,有什么帮助吗?请问?
像智者说的应该是
<ul *ngFor="#store of stores">
<li *ngFor="#person of store.people">
<span *ngIf="store.people.length > 1">Show this</span>
</li>
</ul>