New page Created Module.ts file

When working with a new page, you have 3 choices:

  1. ionic 2 way: add page component/class(eg AboutPage) to @NgModule’s declarations array and entryComponents array in the app.module.ts file. But when you use --prod to build the project, the about.module.ts file will be auto included, so there will be an error complaining duplicate component declarations. To fix this, you must delete the about.module.ts file.
  2. angular 4 NgModule way: ionic 3 cli generate page with a .module.ts file, which makes the page an angular 4 ngmodule (checkout https://angular.io/guide/ngmodule). You need to add the page module(eg AboutPageModule) to @NgModule’s imports array in the app.module.ts file.
  3. ionic 3 lazy loading way: you do nothing with the app.module.ts file, but need to change this.navCtrl.push(AboutPage); to this.navCtrl.push(“AboutPage”); . That is change class to classname STRING .
12 Likes