Angular Entry Components - Explained
Two main kinds of entry components. Let's explore!

• Full Stack Engineer • Auth0Ambassador • Organizer at AngularHive community • Speaker • Blogger
Search for a command to run...
Two main kinds of entry components. Let's explore!

• Full Stack Engineer • Auth0Ambassador • Organizer at AngularHive community • Speaker • Blogger
No comments yet. Be the first to comment.
Hello awesome people👋, welcome back! In this post, I am going to walk you through how to set up Tailwind CSS in an Angular project. It is going to be the easiest setup you have ever done. Come on in. This post is for projects that are using Angular ...

Hello awesome people👋, welcome back! This is again a super simple post about Angular, but pretty informative and you might have not read about it so far. Let's begin. What is Text Interpolation? Interpolation refers to embedding expressions or just ...

Hello awesome people👋, welcome back. This blog post is going to be a super simple post, and I just wanna share my TailWind CSS learning with you all. What are we going to design? A simple and minimalistic card component with 100% TailWind CSS. Code...

Hello amazing people👋, welcome back! Introduction If you are from a Java background, you must have used/heard about Apache Tomcat server, which is a default server any Java developer works with to deal with Web app development. The landscape has cha...

Project documentation serves as a guide for new developers in a team. Why not create one for an Angular project?

Hello awesome people👋, welcome back.
In this post, I am going to deep dive into Entry components in Angular.
As you may know, the entry component is a component that is dynamically loaded into view. A set of components can be listed in the @NgModule.entryComponents property, that is compiled and readily available for rendering within the Module.
Entry components have been deprecated with the introduction of the Ivy rendering engine. We no longer needed to specify entry components in
@NgModulesince Ivy just takes care of them.
You still need to have entryComponents property in @NgModule if your components are going to be consumed by a View Engine application rather than HTML.
A component that is specified in the bootstrap array in the NgModule decorator (of AppModule) is a bootstrap component, that gets loaded into DOM when the app is accessed.

We can have more than one bootstrap component, I explained that further down below.
This is the second type of Entry component specified in the Router configuration.

All the router components specified in the router configuration are entry components.
Even though we don't specify all these components in the entryComponents array in NgModule, the compiler just adds them to the array.
Smart, isn't it?
Oh yes, you can. 👍
Assume your index.html has three components as shown below:
<body>
<app-root></app-root>
<comp-a></comp-a>
<comp-b></comp-b>
</body>
These three components need to be bootstrapped and must be listed in the bootstrap array in the NgModule decorator of AppModule.
@NgModule({
declarations: [
AppComponent,
ComponentA,
ComponentB
],
imports: [
BrowserModule
],
providers: [],
bootstrap: [AppComponent, ComponentA, ComponentB]
})
Just explained the bootstrap process here:
index.html gets loaded first which calls main.ts.main.ts bootstraps 'AppModule`.bootstrap array in AppModule get bootstrapped.
Build your Angular app using the command ng build.
Search for bootstrap:[ in main.ts in the final build, you will see the list of bootstrap components in the bootstrap array.
They don't have the same components name as you have in the code, they will be with random characters.
Like this: bootstrap:[Ll,Zl,zl]
Further search for LI, Zl, and zl (case sensitive search), will fetch you the components' Selectors:
.
.
let Ll=(()=>{class t{constructor()
{this.title="Hello World"}}return t.\u0275fac=function(e)
{return new(e||t)},t.\u0275cmp=Mt({type:t,selectors:[["app-root"]],
.
.
Zl=(()=>{class t{constructor(){}ngOnInit(){}}
return t.\u0275fac=function(e){
return new(e||t)},t.\u0275cmp=Mt({type:t,selectors:[["comp-a"]],
.
.
zl=(()=>{class t{constructor(){}ngOnInit(){}}
return t.\u0275fac=function(e){
return new(e||t)},t.\u0275cmp=Mt({type:t,selectors:[["comp-b"]]
@NgModule.declarations will not get loaded into the final build. bootstrap array [1] (or) the components that are used in the template [2] (or) the router components [3] will only go into the final build.Hope you find this article useful, please feel free to share it with your friends/colleagues.
If you got any questions, feel free to post them in the comments section down below.
Happy learning!
I tweet a lot about Web development, Java, and Productivity Hacks, so feel free to follow me on Twitter at AskUdhay.
Here is one of my recent tweets:
https://angular.io/guide/entry-components