【发布时间】:2019-02-08 08:11:31
【问题描述】:
我在 Ionic v3 中处理一个自定义组件,我正在尝试使用 ngFor。
在我的 .ts 文件中,我的 ngOnInit 中有这个:
this.nb_stars = [];
for(let i=1; i<=4; i++) {
this.nb_stars.push(i);
}
在我的 .html 中我有这个:
<div *ngFor="let star in nb_stars">
test
</div>
但我有这个错误:
未捕获的错误:模板解析错误:无法绑定到“ngForIn”,因为 它不是“div”的已知属性。 (" --> ]*ngFor="在 nb_stars 中测试">
"): ng:///ComponentsModule/CompStarsComponent.html@3:5 属性 嵌入模板上的任何指令均未使用绑定 ngForIn。
确保属性名称拼写正确且所有 指令列在“@NgModule.declarations”中。 (" --> [错误->]
如果有人可以帮助我。
【问题讨论】:
-
语法是
for of不是for in -
我遇到了与 for of 相同的错误...
标签: angular ionic3 components ngfor