Search This Blog

Tuesday, December 17, 2024

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


Recently encountered error below while building an app in Angular

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

Pretty simple fix is that imoer common module in your component something like below

import { CommonModule } from '@angular/common';

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

Error should disappear.

Enjoy coding !!!

Cheers,
Kapil

No comments:

Post a Comment

Thanks for your comment, will revert as soon as we read it.

Popular Posts