简体   繁体   English

无法绑定到“ngForOf”,因为它不是“div”的已知属性。 ngFor 不在浏览器中显示任何内容

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

HTML: HTML:

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

TS: 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.好的,所以这些是我的文件,我在其中创建变量并使用模拟值在 TS 中初始化它的部分,以及当我使用 ngFor 属性在 HTML 中调用它时的部分。 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'. NG0303:无法绑定到“ngForOf”,因为它不是“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.是的,我在 app.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.我不知道您遇到了什么问题,但我尝试在这个项目中制作简单的 ngFor 并且工作正常。

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

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法绑定到“ngForOf”,因为它不是 ngFor Angular 中“li”的已知属性 - Can't bind to 'ngForOf' since it isn't a known property of 'li' in ngFor Angular 无法绑定到“ngForOf”,因为它不是“div”的已知属性。 - App.module.ts 已经有正确的引用 - Can't bind to 'ngForOf' since it isn't a known property of 'div'. - App.module.ts already has right references 无法绑定到“ useStickyClasses”,因为它不是“ div”的已知属性 - Can't bind to 'useStickyClasses' since it isn't a known property of 'div' 无法绑定到“数据集”,因为它不是“画布”的已知属性 - Can't bind to 'datasets' since it isn't a known property of 'canvas' 无法绑定,因为它不是选择器组件的已知属性 - Can't bind to since it isn't a known property of selector component 无法绑定到“”,因为它不是“ angular 2”的已知属性 - can't bind to '' since it isn't a known property of '' angular 2 无法绑定到“appIfRoles”,因为它不是“p”的已知属性 - Can't bind to 'appIfRoles' since it isn't a known property of 'p' 无法绑定到“ chartType”,因为它不是“ canvas”的已知属性 - Can't bind to 'chartType' since it isn't a known property of 'canvas' 错误:无法绑定到“ ngModel”,因为它不是的已知属性 - Error: Can't bind to 'ngModel' since it isn't a known property of 无法绑定到“已禁用”,因为它不是&#39; <button>&#39;</button>的已知属性 - Can't bind to 'disabled' since it isn't a known property of '<button>'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM