I got 35 page classes or so. Is it really necessary for me to include all those pages inside app.module.ts? Seriously?
you can do something like this:
create a new file pages.ts
and export a constant with all the pages like this:
import { PageOneComponent } from './one.component';
import { PageTwoComponent } from './two.component';
import { PageThreeComponent } from './three.component';
export const pages = [
PageOneComponent,
PageTwoComponent,
PageThreeComponent
];
then in your app.module.ts
import { NgModule } from '@angular/core';
import { IonicApp, IonicModule } from 'ionic-angular';
import { pages } from './pages';
@NgModule({
declarations: [
...pages
],
imports: [
IonicModule.forRoot(MyApp)
],
bootstrap: [IonicApp],
entryComponents: [
...pages
],
providers: []
})
export class AppModule {}
just a suggestion
I think a better solution would be to not have 30+ pages.
These pages should be dynamic components, where the templates contents should be updated.
Hello! Thanks for using Ionic! This is an Angular 2 thing related to ngModules and is not Ionic specific. Also, I would look into decreasing the number of pages you have. With 35 separate pages you are going to have a huge bundle and slow performance. It is generally recommended to make generic templates that you can then use multipurpose by simply loading different content into that template.
Just to add a bit about why the pages need to be declared up front.
Since the compilation process is done during a build process now, they compiler needs to know about things up front. This allows the compiler to build out the component tree and bundle everything together. Without declaring these up front, your app will not be providing the necessary information in order to run.
@mhartington Sorry to write on a closed issue, but I stumbled upon this and was curious to know what is the reason 30+ pages seem like a bad practice. In our app we have about 30 pages (all distinct in content and functionality), 50+ components (parts of pages and reusable components). Is this considered bad? The application is pretty huge (the above plus 80+ providers) and wasn't aware that there is a limitation on the number of pages or components. Also are pages any different than components in that matter?
Shouldn't the angular cli automatically add those class imports to module.ts?
Thanks!
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.
Most helpful comment
@mhartington Sorry to write on a closed issue, but I stumbled upon this and was curious to know what is the reason 30+ pages seem like a bad practice. In our app we have about 30 pages (all distinct in content and functionality), 50+ components (parts of pages and reusable components). Is this considered bad? The application is pretty huge (the above plus 80+ providers) and wasn't aware that there is a limitation on the number of pages or components. Also are pages any different than components in that matter?