Ionic 3 gotchas…

Custom Component not working?

With Ionic 3 Lazy Loading feature, you don’t need to add your component into the declarations array in the app.module.ts file.

Instead, add it to the page’s module file where you wish to use this component.

For example, I want to use the custom component ZoomControls on my home page, just add ZoomControls into the file home.module.ts and into the declarations array, and import it at the top of the file.

import { ZoomControls } from '../../components/zoom-controls/zoom-controls';
import { NgModule } from '@angular/core';
import { IonicPageModule } from 'ionic-angular';
import { Home } from './home';

@NgModule({
  declarations: [
    Home, ZoomControls
  ],
  imports: [
    IonicPageModule.forChild(Home),
  ],
  exports: [
    Home
  ]
})
export class HomeModule {}


Follow me

Sean Wu

I love coding, and I believe I can make your life easier with my coding skills. I also love making cool websites and innovative apps. Oh, did I mention I'm a coffee junkie too?
Follow me

Latest posts by Sean Wu (see all)

Ionic 3 notes

Leave a Reply

Your email address will not be published. Required fields are marked *