@for loop not working properly in nz-dropdown

Discussão em 'Angular' iniciado por Redhewlett, Outubro 24, 2024.

  1. Redhewlett

    Redhewlett Guest

    i am working on a dropdown menu that can have its items passed by input. using the dropdown menu from ng-zorro here is the code:

    <nz-dropdown-menu #menu="nzDropdownMenu">
    <ul nz-menu>
    @for (item of menu; track $index) {
    <li nz-menu-item (click)="menuItemclicked(item)">
    {{ item }}
    </li>
    }
    </ul>
    </nz-dropdown-menu>


    and the @input

    @Input() public menu: string[] = []


    In this code the menu in my loops is marked with and error: Type 'NzDropdownMenuComponent' must have a 'Symbol.iterator' method that returns an iterator.

    when i rewrite the code with the old ngFor it works...

    <li *ngFor="let item of menu; let i = index" nz-menu-item (click)="menuItemclicked(item)">
    {{ item }}
    </li>


    Any idea what is the issue here? ps: it compiles

    Continue reading...

Compartilhe esta Página