我正在尝试在 ionic 3 中创建一个自定义组件,但我似乎不知道如何正确设置 components.module 以便我可以在我的组件中使用 ionic 组件
我像这样生成了组件
$: ionic g component my-component
当我添加
<ion-row>
<ion-col>
</ion-col>
</ion-row
到 my-component.html
我得到了错误
Uncaught (in promise): Error: Template parse errors: 'ion-col' is not a known element
最佳答案
使用
ionic generate component my-component
它将在 components
文件夹下的共享模块 components.module.ts
中自动声明。
因此,如果您需要使用该组件,只需在页面模块中导入上述共享模块即可。
components.module.ts
(共享)
import { IonicPageModule } from 'ionic-angular';
@NgModule({
declarations:[MyComponentComponent],
imports:[
IonicPageModule.forChild(MyComponentComponent) // <- Add
],
exports: [MyComponentComponent]
})
关于angular - 未捕获( promise ): Error: Template parse errors: 'ion-col' is not a known element,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45716172/