skip to content
Alvin Lucillo

Structural directive *ngFor

/ 1 min read

💻 Tech

If you see this error on your Angular app, it’s probably that you didn’t import CommonModule which is required if you’re going to use structural directive.

app.component.html:7 NG0303: Can't bind to 'ngForOf' since it isn't a known property of 'li' (used in the '_AppComponent' component template).

If 'li' is an Angular component and it has the 'ngForOf' input, then verify that it is included in the '@Component.imports' of this component.
To allow any property add 'NO_ERRORS_SCHEMA' to the '@Component.schemas' of this component.

Where you use the directive:

<li *ngFor="let personne of personnes">
{{ personne }}
</li>

Where you should import CommonModule

import { Component } from '@angular/core';
import { RouterOutlet } from '@angular/router';
import { CommonModule } from '@angular/common';


@Component({
  selector: 'app-root',
  standalone: true,
  imports: [CommonModule],
  templateUrl: './app.component.html',
  styleUrl: './app.component.css'
})