• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Jj Roberts
  • Al Hobbs
  • Piet Souris

Relationship between Angular 2 and the html page

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 30
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Outstanding !  Thanks.  I will be ordering the book from Barnes& Noble in the morning.   Thank you.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic