3

Here again, I have the following component 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"
        }]
    }];

 }

Now I am looking to count the people inside of each branch. For example 456392 has two manager or 456393 just have one

I tried myself with

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

But I am losing in some point, any help? please?

1
  • 3
    I think you want to check 'people.length' instead of 'person.length'. person is an object, not an array. Commented May 24, 2016 at 1:28

1 Answer 1

5

Like awiseman mentioned it should be

<ul *ngFor="#store of stores">
    <li *ngFor="#person of store.people">
        <span *ngIf="store.people.length > 1">Show this</span>
    </li>
 </ul>
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks mate! I appreciate your help

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.