Friday, 7 November 2014

Anatomy of an AngularJS Application - Part 1

Invoking Angular

Any application must do two things to start Angular:
1. Load the angular.js library
2. Tell Angular which part of the DOM it should manage with the ng-app directive

Loading the Script

Loading the library is straightforward and follows the same rules as any other JavaScript
library. You can load the script from Google’s content delivery network (CDN), like so:

<script
 src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.4/angular.min.js">
</script>

Using Google’s CDN is recommended. Google’s servers are fast, and the script is cache‐
able across applications. That is, if your user has multiple apps that use Angular, she’ll
have to download only it once. Also, if the user has visited other sites that use the Google
CDN link for Angular, she won’t need to download it again when visiting your site.

If you prefer to host locally (or anywhere else), you can do that too. Just specify the
correct location in the src

No comments:

Post a Comment