Reputation: 33
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?
Upvotes: 3
Views: 3409
Reputation: 155
When someone visits your site index.html will be the first file served. Form here the javascript will be loaded which will then bootstrap Angular. The Angular CLI automatically adds the import for your javascript to index.html during the build (ng build
). Build your application and look in your build directory (dist/ by default) you will find the index.html and inside it there will be some script tags: something like: <script src="main.123.js"></script>
. This is the compiled version of main.ts and is how main.ts is loaded and executed in your application.
You can see how the angular app is structured here: https://angular.io/guide/file-structure. If you find index.html on this page it explains how this is the entrypoint to your app.
Upvotes: 1
Reputation: 933
https://dev.to/casperns/how-angular-trigger-indexhtml-and-start-working-1l46
Upvotes: 2