The `*ngFor` directive was used in the template, but neither the `NgFor` directive nor the...

Discussão em 'Angular' iniciado por Raquel Oliveira, Setembro 4, 2025.

  1. I'm new to angular and I can't use the ngFor component. This is the error:

    The *ngFor directive was used in the template, but neither the NgFor directive nor the CommonModule was imported. Use Angular's built-in control flow @for or make sure that either the NgFor directive or the CommonModule is included in the @Component.imports array of this component.

    And this is the code:

    <h2>List</h2>

    <ul>
    <li *ngFor="let c of contacts">
    {{c.id}} - {{c.name}}
    </li>
    </ul>

    Continue reading...

Compartilhe esta Página