When I create a new page component, I now have to place it in declarations as well as entryComponents Array. Why does it have to be at both the places ?
e.g I just created a new login.page.ts file, but i have to declare it in both declarations and entryComponents array (btw its not a entryComponent so to speak)
app.module.ts
@NgModule({
declarations: [
MyApp,
LoginPage
],
imports: [
IonicModule.forRoot(MyApp),
],
bootstrap: [IonicApp],
entryComponents: [
MyApp,
LoginPage
],
providers: [{provide: ErrorHandler, useClass: IonicErrorHandler}]
})
export class AppModule {}
The reason for
entryComponents
is nicely explained in this blog entry:The least we can try is to avoid code duplication. There's not much freedom for dynamic code in the annotations. Trying generate
entryComponents
using an expression likewill result in:
Trying to use an exported function like this
results in:
Fortunately there is a solution. You can use array spread operator here:
Placing an entryComponent should really not be required if the rest of your application is configured properly.
From: https://angular.io/docs/ts/latest/cookbook/ngmodule-faq.html#!#q-when-entry-components