Search code examples
angularangular6angular7angular8

How Angular Application Run? which file executes first?


Are main.ts and index.html runs parallelly? if no, which file runs first? if main.ts, then how angular knows that it should display index.html in browser?


Solution

  • https://dev.to/casperns/how-angular-trigger-indexhtml-and-start-working-1l46

    • Angular started with main.ts.
    • Then we bootstrap an angular application and we pass app.module.ts as an argument. In app.module.ts we tell angular: "There is the app component which you should know when you try to start yourself".
    • And angular now analyze this app component, reading the set up we pass there and there is SELECTOR app-root.
    • Now, angular is enable to handle app-root in the index.html and knows rules for the SELECTOR.
    • SELECTOR should insert the app components and have some HTML code - a template attached to him - html component.
    • This is how Angular application starts.