简体   繁体   中英

Can't bind to 'ngForOf' since it isn't a known property of 'div'. ngFor not displaying anything in the browser

HTML:

<div class="navigation" *ngFor="let nav of navList">
      {{ nav }} 
</div>

TS:

@Input() navList: string[] = ['test1', 'test2', 'test3'];

Ok, so these are my files, the parts where i create the variable and initialize it in the TS with the mock values, and when i call it in the HTML using the ngFor property. Nothing is displayed in the web page and this is the error it returns:

NG0303: Can't bind to 'ngForOf' since it isn't a known property of 'div'.

And yes, I have the Common Module and the Browser module and the browser animation module all imported in the app.module and in the component's module. Does anyone know what else should i do to fix this?

I don't know what problem you are having but I tried to make simple ngFor in this project and work fine.

https://stackblitz.com/edit/angular-ivy-beeizd?file=src/app/app.component.html

如果您没有在 app.module.ts 的声明中声明,它可能会发生。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM