Reputation: 61
suppose i have three component i.e. componentA,componentB,componentC
so is that important to import all three component ? reason ?
like below in
app.module.ts
@NgModule({
declarations: [**componentA**,**componentB**,**componentC** ],
entryComponents: [**componentA**,**componentB**,**componentC**]
Please provide some description
Upvotes: 0
Views: 1662
Reputation: 9764
It depends on your requirements. If you are displaying these components in the first page. It's need to be added in app.module. If you want to loaded these components on subsequent screens. You can opt for Lazy loading Modules.
Move components to their own module and loaded those on demand. This will definitely improve the app load time performance.
Regarding Entry Components, Angular complier will compile all the components defined in the HTML template. Entry Components are those that are not defined in template files. We are telling angular compiler to compile those components defined in entry component configuration which will be included in the application at run time.
Upvotes: 1
Reputation: 1499
An entry component is any component that Angular loads imperatively, (which means you’re not referencing it in the template), by type. You specify an entry component by bootstrapping it in an NgModule, or including it in a routing definition.
There are other components as well which are not bootstrapped imperatively i.e, not on entry as the application loads up bootstrapping
To contrast the two types of components, there are components which are included in the template, which are declarative. Additionally, there are components which you load imperatively; that is, entry components
Please have a look at this https://angular.io/guide/entry-components
Upvotes: 0