Custom Components IONIC 4

故事扮演 提交于 2019-12-13 03:17:44

问题


I have an ionic app and created a custom component for ion-navbar but, how could I use this component in all of my pages? If I declare him on all the pages i get this error

Here's my Github if u want https://github.com/tiagosilveiraa/PManager


回答1:


You can create a shared module and include that new shared module as an import for the page modules that need the header:

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 {}

Then for the home.module.ts

@NgModule({
  imports: [
    CommonModule,
    FormsModule,
    IonicModule,
    SharedModule,
    RouterModule.forChild(routes),  
  ],
  declarations: [HomePage]
})
export class HomePageModule {}


来源:https://stackoverflow.com/questions/54990598/custom-components-ionic-4

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!