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

Ionic 3 can't use ion-* components inside my custom components

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

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

中导入 IonicModule.forRoot(..)

错误是:

"Template parse errors: 'ion-spinner' is not a known element ..."

我做错了什么?

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

我只需要在 components.module 中导入 IonicModule 而无需 forRoot(..).

另请注意,Angular 的 CommonModule 也是使 Angular 的指令起作用所必需的,因此您可能也需要导入它。

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

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