Win a copy of Bad Programming Practices 101 (e-book) this week in the Beginning Java forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Relationship between Angular 2 and the html page  RSS feed

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello.  Thanks for providing this Forum.
I have studied a few Angular2 tutorials on YouTube,  but am very curious:

How does the browser know which Angular2 Application to run when an HTML page is loaded from the Server into the browser ?  There must be some meta-data somewhere that creates an association between the html page being loaded,  and the AngularJS2 application that reacts to the page.  Right ?    Or am I going in the wrong direction ?

Tanks for you answer in advance.
 
Author
Greenhorn
Posts: 25
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess you are confused because you don't know how the Webpack bundler (Angular CLI uses it) works.  In chapter 10 of our book, we explain how to configure the Webpack manually: configure the entry points, split the code into multiple bundles and include them into index.html. Angular CLI generates the config files (and the main entry point of the app) automatically based on the information in the angular-cli.json.

When you run ng serve, all this magic happens in memory and you can't see the link between the index.html located in the src dir and the bundle(s). But if you run the ng build command, it'll create the folder dist, puts the new version of index.html and the bundles there. Open the file dist/index.html and you'll see the script tags that explicitly mention the bundles with the app.

Regards
Yakov
 
Andrew Jerpe
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Outstanding !  Thanks.  I will be ordering the book from Barnes& Noble in the morning.   Thank you.
 
I'm so happy! And I wish to make this tiny ad happy too:
Why should you try IntelliJ IDEA ?
https://coderanch.com/wiki/696337/IntelliJ-IDEA
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!