*ngFor 在模态内部不起作用 (angular 10 ionic 5)

*ngFor doesn't work inside modal (angular 10 ionic 5)

我在我的项目中遇到了一个问题,*ngFor 在模态组件中不起作用,但在其他任何地方都起作用。我在应用程序组件中导入 BrowserModule,在其他地方导入 commonModule。 没有拼写错误。 我确定声明已明确声明。

错误是:

Can't bind to 'ngForOf' since it isn't a known property of 'li'

有什么帮助吗?

我刚刚在这个 link 中找到了答案: Add the component to your app.module 您应该在根应用程序模块中添加模态组件的位置: 首先在您的 app.module,

中导入模态页面
import {ModalPage} from "./home/modal.page"

然后在 declarations 和 entryComponents 中声明它

declarations: [AppComponent,ModalPage],

entryComponents: [ModalPage],