What is entryComponents in angular ngModule?
I am working on an Ionic
app ( 2.0.0-rc0
) which depends on angular 2
. So the new introduction of ngModules
is included. I am adding my app.module.ts.
below.
import { NgModule } from '@angular/core';
import { IonicApp, IonicModule } from 'ionic-angular';
import { MyApp } from './app.component';
import { Users } from '../pages/users/users';
@NgModule({
declarations: [
MyApp,
Users
],
imports: [
IonicModule.forRoot(MyApp)
],
bootstrap: [IonicApp],
entryComponents: [
MyApp,
Users
]
})
export class AppModule {}
What does entryComponents
do here? Components
are already defined in declarations
. So what's the need of repeating them ? What would happen if I dont include a component here?
angular ionic-framework ionic2
add a comment |
I am working on an Ionic
app ( 2.0.0-rc0
) which depends on angular 2
. So the new introduction of ngModules
is included. I am adding my app.module.ts.
below.
import { NgModule } from '@angular/core';
import { IonicApp, IonicModule } from 'ionic-angular';
import { MyApp } from './app.component';
import { Users } from '../pages/users/users';
@NgModule({
declarations: [
MyApp,
Users
],
imports: [
IonicModule.forRoot(MyApp)
],
bootstrap: [IonicApp],
entryComponents: [
MyApp,
Users
]
})
export class AppModule {}
What does entryComponents
do here? Components
are already defined in declarations
. So what's the need of repeating them ? What would happen if I dont include a component here?
angular ionic-framework ionic2
4
Angular uses entryComponents to enable "tree shaking" i.e. only compiling the components that are actually used in the project instead of compiling all the components that aredeclared
inngModule
but are never used. angular.io/docs/ts/latest/cookbook/…entrycomponents-
– Samar
Mar 24 '17 at 7:28
add a comment |
I am working on an Ionic
app ( 2.0.0-rc0
) which depends on angular 2
. So the new introduction of ngModules
is included. I am adding my app.module.ts.
below.
import { NgModule } from '@angular/core';
import { IonicApp, IonicModule } from 'ionic-angular';
import { MyApp } from './app.component';
import { Users } from '../pages/users/users';
@NgModule({
declarations: [
MyApp,
Users
],
imports: [
IonicModule.forRoot(MyApp)
],
bootstrap: [IonicApp],
entryComponents: [
MyApp,
Users
]
})
export class AppModule {}
What does entryComponents
do here? Components
are already defined in declarations
. So what's the need of repeating them ? What would happen if I dont include a component here?
angular ionic-framework ionic2
I am working on an Ionic
app ( 2.0.0-rc0
) which depends on angular 2
. So the new introduction of ngModules
is included. I am adding my app.module.ts.
below.
import { NgModule } from '@angular/core';
import { IonicApp, IonicModule } from 'ionic-angular';
import { MyApp } from './app.component';
import { Users } from '../pages/users/users';
@NgModule({
declarations: [
MyApp,
Users
],
imports: [
IonicModule.forRoot(MyApp)
],
bootstrap: [IonicApp],
entryComponents: [
MyApp,
Users
]
})
export class AppModule {}
What does entryComponents
do here? Components
are already defined in declarations
. So what's the need of repeating them ? What would happen if I dont include a component here?
angular ionic-framework ionic2
angular ionic-framework ionic2
edited Jan 23 '17 at 7:21
raj
asked Sep 28 '16 at 19:35
rajraj
3,37232342
3,37232342
4
Angular uses entryComponents to enable "tree shaking" i.e. only compiling the components that are actually used in the project instead of compiling all the components that aredeclared
inngModule
but are never used. angular.io/docs/ts/latest/cookbook/…entrycomponents-
– Samar
Mar 24 '17 at 7:28
add a comment |
4
Angular uses entryComponents to enable "tree shaking" i.e. only compiling the components that are actually used in the project instead of compiling all the components that aredeclared
inngModule
but are never used. angular.io/docs/ts/latest/cookbook/…entrycomponents-
– Samar
Mar 24 '17 at 7:28
4
4
Angular uses entryComponents to enable "tree shaking" i.e. only compiling the components that are actually used in the project instead of compiling all the components that are
declared
in ngModule
but are never used. angular.io/docs/ts/latest/cookbook/…entrycomponents-– Samar
Mar 24 '17 at 7:28
Angular uses entryComponents to enable "tree shaking" i.e. only compiling the components that are actually used in the project instead of compiling all the components that are
declared
in ngModule
but are never used. angular.io/docs/ts/latest/cookbook/…entrycomponents-– Samar
Mar 24 '17 at 7:28
add a comment |
4 Answers
4
active
oldest
votes
This is for dynamically added components that are added using ViewContainerRef.createComponent()
. Adding them to entryComponents
tells the offline template compiler to compile them and create factories for them.
The components registered in route configurations are added automatically to entryComponents
as well because router-outlet
also uses ViewContainerRef.createComponent()
to add routed components to the DOM.
Offline template compiler (OTC) only builds components that are actually used. If components aren't used in templates directly the OTC can't know whether they need to be compiled. With entryComponents you can tell the OTC to also compile this components so they are available at runtime.
What is an entry component? (angular.io)
NgModule docs (angular.io)
Defines the components that should be compiled as well when this component is defined. For each components listed here, Angular will create a ComponentFactory and store it in the ComponentFactoryResolver.
If you don't list a dynamically added component to entryComponents
you'll get an error message a bout a missing factory because Angular won't have created one.
See also https://angular.io/docs/ts/latest/cookbook/dynamic-component-loader.html
6
frankly speaking, I know its 100% correct answer but went bouncer for me, could you please elaborate more?
– Pankaj Parkar
Sep 28 '16 at 19:39
21
Hard to tell what's unclear. Offline template compiler (OTC) only builds components that are actually used. If components aren't used in templates directly the OTC can't know whether they need to be compiled. WithentryComponents
you can tell the OTC to also compile this components so they are available at runtime.
– Günter Zöchbauer
Sep 28 '16 at 19:43
Thanks Gunter . Can you give me a scenario in which not adding components inentryComponents
would cause some issue?
– raj
Sep 28 '16 at 19:46
3
stackoverflow.com/questions/36325212/… would be such an example
– Günter Zöchbauer
Sep 28 '16 at 19:48
1
So in general, if component is listed indeclarations
it should also be listed inentryComponents
, right?
– omnomnom
Dec 13 '16 at 7:00
|
show 4 more comments
You won't get explanation better than Angular docs.
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.
Right now the angular docs are not available, so thank SO for that!
– Caelum
Feb 28 '18 at 11:43
This doesn't seem to mention that components in route configurations are automatically added to entryComponents (so you usually never need to define it).
– Connor
Jan 29 at 16:11
add a comment |
The other answers mention this but the basic summary is:
- its needed when a component is not used inside an html template.
- For example when using Angular Material dialog components
Material dialog components are created inside the TS code and not the template:
openDialog() {
const dialogRef = this.dialog.open(MyExampleDialog, { width: '250px' });
}
This requires you to register it as an entryComponent:
entryComponents: [MyExampleDialog]
Otherwise you get a error:
ERROR Error: No component factory found for MyExampleDialog. Did you add it to @NgModule.entryComponents?
add a comment |
The entryComponents array is used to define only components that are not found in html and created dynamically. Angular requires this hint to find entry component and compile them.
There are two main types of entry components:
- The bootstrapped root component.
- A component you specify in a route definition.
For more detailed information around entry components, please refer angular.io
https://angular.io/guide/entry-components
add a comment |
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f39756192%2fwhat-is-entrycomponents-in-angular-ngmodule%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
This is for dynamically added components that are added using ViewContainerRef.createComponent()
. Adding them to entryComponents
tells the offline template compiler to compile them and create factories for them.
The components registered in route configurations are added automatically to entryComponents
as well because router-outlet
also uses ViewContainerRef.createComponent()
to add routed components to the DOM.
Offline template compiler (OTC) only builds components that are actually used. If components aren't used in templates directly the OTC can't know whether they need to be compiled. With entryComponents you can tell the OTC to also compile this components so they are available at runtime.
What is an entry component? (angular.io)
NgModule docs (angular.io)
Defines the components that should be compiled as well when this component is defined. For each components listed here, Angular will create a ComponentFactory and store it in the ComponentFactoryResolver.
If you don't list a dynamically added component to entryComponents
you'll get an error message a bout a missing factory because Angular won't have created one.
See also https://angular.io/docs/ts/latest/cookbook/dynamic-component-loader.html
6
frankly speaking, I know its 100% correct answer but went bouncer for me, could you please elaborate more?
– Pankaj Parkar
Sep 28 '16 at 19:39
21
Hard to tell what's unclear. Offline template compiler (OTC) only builds components that are actually used. If components aren't used in templates directly the OTC can't know whether they need to be compiled. WithentryComponents
you can tell the OTC to also compile this components so they are available at runtime.
– Günter Zöchbauer
Sep 28 '16 at 19:43
Thanks Gunter . Can you give me a scenario in which not adding components inentryComponents
would cause some issue?
– raj
Sep 28 '16 at 19:46
3
stackoverflow.com/questions/36325212/… would be such an example
– Günter Zöchbauer
Sep 28 '16 at 19:48
1
So in general, if component is listed indeclarations
it should also be listed inentryComponents
, right?
– omnomnom
Dec 13 '16 at 7:00
|
show 4 more comments
This is for dynamically added components that are added using ViewContainerRef.createComponent()
. Adding them to entryComponents
tells the offline template compiler to compile them and create factories for them.
The components registered in route configurations are added automatically to entryComponents
as well because router-outlet
also uses ViewContainerRef.createComponent()
to add routed components to the DOM.
Offline template compiler (OTC) only builds components that are actually used. If components aren't used in templates directly the OTC can't know whether they need to be compiled. With entryComponents you can tell the OTC to also compile this components so they are available at runtime.
What is an entry component? (angular.io)
NgModule docs (angular.io)
Defines the components that should be compiled as well when this component is defined. For each components listed here, Angular will create a ComponentFactory and store it in the ComponentFactoryResolver.
If you don't list a dynamically added component to entryComponents
you'll get an error message a bout a missing factory because Angular won't have created one.
See also https://angular.io/docs/ts/latest/cookbook/dynamic-component-loader.html
6
frankly speaking, I know its 100% correct answer but went bouncer for me, could you please elaborate more?
– Pankaj Parkar
Sep 28 '16 at 19:39
21
Hard to tell what's unclear. Offline template compiler (OTC) only builds components that are actually used. If components aren't used in templates directly the OTC can't know whether they need to be compiled. WithentryComponents
you can tell the OTC to also compile this components so they are available at runtime.
– Günter Zöchbauer
Sep 28 '16 at 19:43
Thanks Gunter . Can you give me a scenario in which not adding components inentryComponents
would cause some issue?
– raj
Sep 28 '16 at 19:46
3
stackoverflow.com/questions/36325212/… would be such an example
– Günter Zöchbauer
Sep 28 '16 at 19:48
1
So in general, if component is listed indeclarations
it should also be listed inentryComponents
, right?
– omnomnom
Dec 13 '16 at 7:00
|
show 4 more comments
This is for dynamically added components that are added using ViewContainerRef.createComponent()
. Adding them to entryComponents
tells the offline template compiler to compile them and create factories for them.
The components registered in route configurations are added automatically to entryComponents
as well because router-outlet
also uses ViewContainerRef.createComponent()
to add routed components to the DOM.
Offline template compiler (OTC) only builds components that are actually used. If components aren't used in templates directly the OTC can't know whether they need to be compiled. With entryComponents you can tell the OTC to also compile this components so they are available at runtime.
What is an entry component? (angular.io)
NgModule docs (angular.io)
Defines the components that should be compiled as well when this component is defined. For each components listed here, Angular will create a ComponentFactory and store it in the ComponentFactoryResolver.
If you don't list a dynamically added component to entryComponents
you'll get an error message a bout a missing factory because Angular won't have created one.
See also https://angular.io/docs/ts/latest/cookbook/dynamic-component-loader.html
This is for dynamically added components that are added using ViewContainerRef.createComponent()
. Adding them to entryComponents
tells the offline template compiler to compile them and create factories for them.
The components registered in route configurations are added automatically to entryComponents
as well because router-outlet
also uses ViewContainerRef.createComponent()
to add routed components to the DOM.
Offline template compiler (OTC) only builds components that are actually used. If components aren't used in templates directly the OTC can't know whether they need to be compiled. With entryComponents you can tell the OTC to also compile this components so they are available at runtime.
What is an entry component? (angular.io)
NgModule docs (angular.io)
Defines the components that should be compiled as well when this component is defined. For each components listed here, Angular will create a ComponentFactory and store it in the ComponentFactoryResolver.
If you don't list a dynamically added component to entryComponents
you'll get an error message a bout a missing factory because Angular won't have created one.
See also https://angular.io/docs/ts/latest/cookbook/dynamic-component-loader.html
edited Nov 14 '17 at 7:53
answered Sep 28 '16 at 19:37
Günter ZöchbauerGünter Zöchbauer
334k721011943
334k721011943
6
frankly speaking, I know its 100% correct answer but went bouncer for me, could you please elaborate more?
– Pankaj Parkar
Sep 28 '16 at 19:39
21
Hard to tell what's unclear. Offline template compiler (OTC) only builds components that are actually used. If components aren't used in templates directly the OTC can't know whether they need to be compiled. WithentryComponents
you can tell the OTC to also compile this components so they are available at runtime.
– Günter Zöchbauer
Sep 28 '16 at 19:43
Thanks Gunter . Can you give me a scenario in which not adding components inentryComponents
would cause some issue?
– raj
Sep 28 '16 at 19:46
3
stackoverflow.com/questions/36325212/… would be such an example
– Günter Zöchbauer
Sep 28 '16 at 19:48
1
So in general, if component is listed indeclarations
it should also be listed inentryComponents
, right?
– omnomnom
Dec 13 '16 at 7:00
|
show 4 more comments
6
frankly speaking, I know its 100% correct answer but went bouncer for me, could you please elaborate more?
– Pankaj Parkar
Sep 28 '16 at 19:39
21
Hard to tell what's unclear. Offline template compiler (OTC) only builds components that are actually used. If components aren't used in templates directly the OTC can't know whether they need to be compiled. WithentryComponents
you can tell the OTC to also compile this components so they are available at runtime.
– Günter Zöchbauer
Sep 28 '16 at 19:43
Thanks Gunter . Can you give me a scenario in which not adding components inentryComponents
would cause some issue?
– raj
Sep 28 '16 at 19:46
3
stackoverflow.com/questions/36325212/… would be such an example
– Günter Zöchbauer
Sep 28 '16 at 19:48
1
So in general, if component is listed indeclarations
it should also be listed inentryComponents
, right?
– omnomnom
Dec 13 '16 at 7:00
6
6
frankly speaking, I know its 100% correct answer but went bouncer for me, could you please elaborate more?
– Pankaj Parkar
Sep 28 '16 at 19:39
frankly speaking, I know its 100% correct answer but went bouncer for me, could you please elaborate more?
– Pankaj Parkar
Sep 28 '16 at 19:39
21
21
Hard to tell what's unclear. Offline template compiler (OTC) only builds components that are actually used. If components aren't used in templates directly the OTC can't know whether they need to be compiled. With
entryComponents
you can tell the OTC to also compile this components so they are available at runtime.– Günter Zöchbauer
Sep 28 '16 at 19:43
Hard to tell what's unclear. Offline template compiler (OTC) only builds components that are actually used. If components aren't used in templates directly the OTC can't know whether they need to be compiled. With
entryComponents
you can tell the OTC to also compile this components so they are available at runtime.– Günter Zöchbauer
Sep 28 '16 at 19:43
Thanks Gunter . Can you give me a scenario in which not adding components in
entryComponents
would cause some issue?– raj
Sep 28 '16 at 19:46
Thanks Gunter . Can you give me a scenario in which not adding components in
entryComponents
would cause some issue?– raj
Sep 28 '16 at 19:46
3
3
stackoverflow.com/questions/36325212/… would be such an example
– Günter Zöchbauer
Sep 28 '16 at 19:48
stackoverflow.com/questions/36325212/… would be such an example
– Günter Zöchbauer
Sep 28 '16 at 19:48
1
1
So in general, if component is listed in
declarations
it should also be listed in entryComponents
, right?– omnomnom
Dec 13 '16 at 7:00
So in general, if component is listed in
declarations
it should also be listed in entryComponents
, right?– omnomnom
Dec 13 '16 at 7:00
|
show 4 more comments
You won't get explanation better than Angular docs.
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.
Right now the angular docs are not available, so thank SO for that!
– Caelum
Feb 28 '18 at 11:43
This doesn't seem to mention that components in route configurations are automatically added to entryComponents (so you usually never need to define it).
– Connor
Jan 29 at 16:11
add a comment |
You won't get explanation better than Angular docs.
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.
Right now the angular docs are not available, so thank SO for that!
– Caelum
Feb 28 '18 at 11:43
This doesn't seem to mention that components in route configurations are automatically added to entryComponents (so you usually never need to define it).
– Connor
Jan 29 at 16:11
add a comment |
You won't get explanation better than Angular docs.
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.
You won't get explanation better than Angular docs.
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.
answered Mar 8 '17 at 19:01
Mav55Mav55
1,4001216
1,4001216
Right now the angular docs are not available, so thank SO for that!
– Caelum
Feb 28 '18 at 11:43
This doesn't seem to mention that components in route configurations are automatically added to entryComponents (so you usually never need to define it).
– Connor
Jan 29 at 16:11
add a comment |
Right now the angular docs are not available, so thank SO for that!
– Caelum
Feb 28 '18 at 11:43
This doesn't seem to mention that components in route configurations are automatically added to entryComponents (so you usually never need to define it).
– Connor
Jan 29 at 16:11
Right now the angular docs are not available, so thank SO for that!
– Caelum
Feb 28 '18 at 11:43
Right now the angular docs are not available, so thank SO for that!
– Caelum
Feb 28 '18 at 11:43
This doesn't seem to mention that components in route configurations are automatically added to entryComponents (so you usually never need to define it).
– Connor
Jan 29 at 16:11
This doesn't seem to mention that components in route configurations are automatically added to entryComponents (so you usually never need to define it).
– Connor
Jan 29 at 16:11
add a comment |
The other answers mention this but the basic summary is:
- its needed when a component is not used inside an html template.
- For example when using Angular Material dialog components
Material dialog components are created inside the TS code and not the template:
openDialog() {
const dialogRef = this.dialog.open(MyExampleDialog, { width: '250px' });
}
This requires you to register it as an entryComponent:
entryComponents: [MyExampleDialog]
Otherwise you get a error:
ERROR Error: No component factory found for MyExampleDialog. Did you add it to @NgModule.entryComponents?
add a comment |
The other answers mention this but the basic summary is:
- its needed when a component is not used inside an html template.
- For example when using Angular Material dialog components
Material dialog components are created inside the TS code and not the template:
openDialog() {
const dialogRef = this.dialog.open(MyExampleDialog, { width: '250px' });
}
This requires you to register it as an entryComponent:
entryComponents: [MyExampleDialog]
Otherwise you get a error:
ERROR Error: No component factory found for MyExampleDialog. Did you add it to @NgModule.entryComponents?
add a comment |
The other answers mention this but the basic summary is:
- its needed when a component is not used inside an html template.
- For example when using Angular Material dialog components
Material dialog components are created inside the TS code and not the template:
openDialog() {
const dialogRef = this.dialog.open(MyExampleDialog, { width: '250px' });
}
This requires you to register it as an entryComponent:
entryComponents: [MyExampleDialog]
Otherwise you get a error:
ERROR Error: No component factory found for MyExampleDialog. Did you add it to @NgModule.entryComponents?
The other answers mention this but the basic summary is:
- its needed when a component is not used inside an html template.
- For example when using Angular Material dialog components
Material dialog components are created inside the TS code and not the template:
openDialog() {
const dialogRef = this.dialog.open(MyExampleDialog, { width: '250px' });
}
This requires you to register it as an entryComponent:
entryComponents: [MyExampleDialog]
Otherwise you get a error:
ERROR Error: No component factory found for MyExampleDialog. Did you add it to @NgModule.entryComponents?
edited Jan 3 at 15:35
answered Jan 3 at 15:30
Mike RMike R
2,61332037
2,61332037
add a comment |
add a comment |
The entryComponents array is used to define only components that are not found in html and created dynamically. Angular requires this hint to find entry component and compile them.
There are two main types of entry components:
- The bootstrapped root component.
- A component you specify in a route definition.
For more detailed information around entry components, please refer angular.io
https://angular.io/guide/entry-components
add a comment |
The entryComponents array is used to define only components that are not found in html and created dynamically. Angular requires this hint to find entry component and compile them.
There are two main types of entry components:
- The bootstrapped root component.
- A component you specify in a route definition.
For more detailed information around entry components, please refer angular.io
https://angular.io/guide/entry-components
add a comment |
The entryComponents array is used to define only components that are not found in html and created dynamically. Angular requires this hint to find entry component and compile them.
There are two main types of entry components:
- The bootstrapped root component.
- A component you specify in a route definition.
For more detailed information around entry components, please refer angular.io
https://angular.io/guide/entry-components
The entryComponents array is used to define only components that are not found in html and created dynamically. Angular requires this hint to find entry component and compile them.
There are two main types of entry components:
- The bootstrapped root component.
- A component you specify in a route definition.
For more detailed information around entry components, please refer angular.io
https://angular.io/guide/entry-components
edited Jan 3 at 16:27
answered Jan 3 at 16:00
sUpEr nInJasUpEr nInJa
408
408
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f39756192%2fwhat-is-entrycomponents-in-angular-ngmodule%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
4
Angular uses entryComponents to enable "tree shaking" i.e. only compiling the components that are actually used in the project instead of compiling all the components that are
declared
inngModule
but are never used. angular.io/docs/ts/latest/cookbook/…entrycomponents-– Samar
Mar 24 '17 at 7:28