我坚持用导入自定义组件插入到页面中的离子3.这是比较琐碎的离子2,但我似乎无法得到它的离子3.离子3导入自定义组件
我有工作一个名为other
的现有页面模块。运行ionic g component test
后,我将自动生成的ComponentsModule
导入到other.module.ts
中,并将其添加到imports
阵列中。
import { ComponentsModule } from "../../components/components.module";
@NgModule({
declarations: [
OtherPage,
],
imports: [
IonicPageModule.forChild(OtherPage),
ComponentsModule,
],
})
export class OtherPageModule {}
然后我添加组件选择器到页面作为<test></test>
。
这将导致一个错误:
polyfills.js:3 Unhandled Promise rejection: Template parse errors:
'test' is not a known element:
1. If 'test' is an Angular component, then verify that it is part of this module.
2. To allow any element add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component. ("
<ion-content padding>
[ERROR ->]<test> </test>
</ion-content>
"): ng:///AppModule/[email protected]:0 ; Zone: <root> ; Task: Promise.then ; Value: Error: Template parse errors:
'test' is not a known element:
1. If 'test' is an Angular component, then verify that it is part of this module.
这并不为我工作。我也尝试为测试组件创建一个module
并以相同的方式导入它,但这不适用于我。
我似乎无法找到任何文档或示例。如何在Ionic 3中导入自定义组件?
您可以为您的整个代码? –
请加入我的Ionic 3聊天室 - https://chat.stackoverflow.com/rooms/153499/ionic-3 –
您需要选择[Component](https://angular.io/api/core/Directive#选择器)定义为“测试” – Efren