Let’s understand how an angular application works from core, what happen when it starts.
In index.html file there is a <app-root> custom html code, this app-root is a selector of app component of application.
During the build process the whole application build is generated and this script filess added to the bottom of index.html files.
app component is connected to the index.html file through its app-root selector.
This app-root selector scope the content of app component html file to index.html file.
In the app.module.ts file we declare this app component and also bootstrap it.
We can only bootstrap one component at a time to make it a root component.
But we can declare multiple components and connect them to each other.
How it start the angular application ?
In main.ts (it execute first) file platformBrowserDynamic() function executes and it start the angular application in browser then we call another function bootstrapModule() function.
Here we pass the link of our own module which is AppModule in this case.
We pass this as an argument and this say angular to start the application.
Now angular parse this module
Register the components which are declared
Import some other modules.
detects bootstrap array and looks for selector of this components.
1 Comment