【发布时间】:2021-02-10 14:14:46
【问题描述】:
我在项目中遇到了一个问题,*ngFor 在模态组件中不起作用,而在其他任何地方都可以使用。我在应用程序组件中导入 BrowserModule,在其他地方导入 commonModule。 没有拼写错误。 我确信声明已明确声明。
错误是:
无法绑定到“ngForOf”,因为它不是“li”的已知属性
有什么帮助吗?
【问题讨论】:
我在项目中遇到了一个问题,*ngFor 在模态组件中不起作用,而在其他任何地方都可以使用。我在应用程序组件中导入 BrowserModule,在其他地方导入 commonModule。 没有拼写错误。 我确信声明已明确声明。
错误是:
无法绑定到“ngForOf”,因为它不是“li”的已知属性
有什么帮助吗?
【问题讨论】:
我刚刚在这个链接中找到了答案: Add the component to your app.module 您应该在根应用程序模块中添加 Modal 组件的位置: 首先在你的app.module中导入Modal页面,
import {ModalPage} from "./home/modal.page"
然后在声明和 entryComponents 中声明它
declarations: [AppComponent,ModalPage],
entryComponents: [ModalPage],
【讨论】: