我有一个离子应用程序,并为ion-navbar
创建了一个自定义组件,但是如何在所有页面中使用该组件?如果我在所有页面上都声明他,则会出现此错误
如果您要https://github.com/tiagosilveiraa/PManager,这是我的Github
答案 0 :(得分:2)
您可以创建一个共享模块,并将新共享模块作为需要标题的页面模块的导入:
shared.module.ts
import { NgModule } from '@angular/core';
import {CommonModule} from '@angular/common';
import {HeaderComponent} from './header/header.component';
import {IonicModule} from '@ionic/angular';
@NgModule({
imports: [
CommonModule,
IonicModule
],
declarations: [HeaderComponent],
exports: [HeaderComponent]
})
export class SharedModule {}
然后输入home.module.ts
@NgModule({
imports: [
CommonModule,
FormsModule,
IonicModule,
SharedModule,
RouterModule.forChild(routes),
],
declarations: [HomePage]
})
export class HomePageModule {}