I am working on an Ionic
app ( 2.0.0-rc0
) which depends on angular 2
. So the new introduction of ngModules
is included.
You won't get explanation better than Angular docs: entry-components and ngmodule-faq.
And below is the explanation from the angular docs.
An entry component is any component that Angular loads imperatively by type.
A component loaded declaratively via its selector is not an entry component.
Most application components are loaded declaratively. Angular uses the component's selector to locate the element in the template. It then creates the HTML representation of the component and inserts it into the DOM at the selected element. These aren't entry components.
A few components are only loaded dynamically and are never referenced in a component template.
The bootstrapped root
AppComponent
is an entry component. True, its selector matches an element tag in index.html. Butindex.html
isn't a component template and theAppComponent
selector doesn't match an element in any component template.Angular loads AppComponent dynamically because it's either listed by type in
@NgModule.bootstrap
or boostrapped imperatively with the module's ngDoBootstrap method.Components in route definitions are also entry components. A route definition refers to a component by its type. The router ignores a routed component's selector (if it even has one) and loads the component dynamically into a
RouterOutlet
.The compiler can't discover these entry components by looking for them in other component templates. You must tell it about them by adding them to the
entryComponents
list.Angular automatically adds the following types of components to the module's
entryComponents
:
- The component in the
@NgModule.bootstrap
list.- Components referenced in router configuration.
You don't have to mention these components explicitly, although doing so is harmless.