*ngFor 在模态内不起作用(angular 10 ionic 5) [英] *ngFor doesn't work inside modal (angular 10 ionic 5)
问题描述
我在我的项目中遇到了一个问题,*ngFor 在模态组件内不起作用,并且在其他任何地方都起作用.我在 app 组件中导入 BrowserModule,在其他地方导入 commonModule.没有拼写错误.我确信声明已明确声明.
I faced an issue inside my project, *ngFor doesn't work inside the modal component, and works anywhere else. I import BrowserModule in the app component, and commonModule elsewhere. There is no spelling mistakes. I am sure the declarative is clearly declared.
错误是:
无法绑定到 'ngForOf',因为它不是 'li' 的已知属性
Can't bind to 'ngForOf' since it isn't a known property of 'li'
有什么帮助吗?
推荐答案
我刚刚在此链接中找到了答案:将组件添加到您的 app.module您应该在根应用程序模块中添加 Modal 组件的位置:首先在你的 app.module 中导入 Modal 页面,
I just found the answer in this link: Add the component to your app.module Where you should add the Modal component in the root app module: First import the Modal page in your app.module,
import {ModalPage} from "./home/modal.page"
然后在声明和 entryComponents 中声明它
then declares it inside declarations and entryComponents
declarations: [AppComponent,ModalPage],
entryComponents: [ModalPage],
这篇关于*ngFor 在模态内不起作用(angular 10 ionic 5)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!