Ionic 3不能在我的自定义组件中使用ion- *组件

时间:2017-04-15 10:45:46

标签: angular ionic2 ionic3

我最近从Ionic 2升级到Ionic 3,我创建了 components.module.ts 文件并声明并导出了我自己的每个自定义组件,然后在每个页面模块中导入了这个单个文件我有。

所以现在问题是我不能在我自己的组件中使用ion- *组件,因为我没有在components.module中导入IonicModule.forRoot(..)

错误是:

  

"模板解析错误:' ion-spinner'不是一个已知的元素......"

我做错了什么?

2 个答案:

答案 0 :(得分:59)

好吧,所以我找到了解决方案:

我只需要导入IonicModule中的components.module forRoot(..)

另请注意,Angular的CommonModule对于使Angular的指令有效也是必要的,因此您可能也需要导入它。

答案 1 :(得分:20)

根据Eliran的回复,这里有一个例子,以防有人需要视觉效果,components.module.ts

@NgModule({
 imports: [
  CommonModule, <<<< add the angular common module
  IonicModule <<<< add the ionic module
 ],
 ...
})
相关问题