How Angular 2 App get started?
Angular 2 is a single page app and will contains only one file called index.html in the root folder. although this html file doennot even contains any js files then how the fuck it get started:
Index file
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>FirstApp</title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
</head>
<body>
<app-root>Loading...</app-root>
</body>
</html>
Well when we compile and run the app then the angular-cli will dynamically add the required js files in the page. Which we can see the source in the page while its running
Well then where the fuck is our code?
The answer is it all we be inside the main.bundle.js file
The answer is it all we be inside the main.bundle.js file
here is the flow
- At first the angular app will always use main.ts file which will bootstrap the our app and create a js file at the run time. Inside teh main.ts file we have
platformBrowserDynamic().bootstrapModule(AppModule);
Which will load the AppModule from the module inside the app directory after importing it using
import { AppModule } from './app/'; - Then the app will use the app.module.ts inside the app dir which will again bootstrap the AppComponent which we have created earlier in this series.
bootstrap: [AppComponent] - The Main this about angular 2 is that it will not load all the component at the beginning. It will only load the component which is in the index.html file which is app-root in our case. Its a lazy loading which will increase the performance.
- So the main flow is
main.ts -> load the main module used in the index.html -> the main module will bootstrap the Component -> then main.ts will bootstrap the app and create a single main.bundle.js and add it to the main page -> then we enjoy :)
Happy Coding geeks. In the next session we will talk about the AppModules \,,/
Thanks a lot for sharing this admin. I learned a lot from your blog and I have bookmarked this page for my future reference. Share more like this.
ReplyDeleteAngularjs Training in Chennai | Angularjs Training | Angularjs course in Chennai
In this blog i noticed new important points, this points are valuable and it is useful for me...
ReplyDeletePHP Training in Bangalore
PHP Training in Chennai
PHP Course in Bangalore
PHP Training Institute in Bangalore
PHP Classes in Bangalore
AWS Training in Bangalore
Data Science Courses in Bangalore
DevOps Training in Bangalore
DOT NET Training in Bangalore
Data Science Course in Chennai
Great information to say the least. I really do appreciate everything so much from this great website.keep sharing more blogs like this.
ReplyDeleteIELTS Coaching in chennai
German Classes in Chennai
GRE Coaching Classes in Chennai
TOEFL Coaching in Chennai
spoken english classes in chennai | Communication training