Chapter 2. Anatomy of an AngularJS Application
Unlike typical libraries where you pick and choose functions as you like, everything in Angular is designed to be used as a collaborative suite. In this chapter we’ll cover all of the basic building blocks in Angular so you can understand how they fit together. Many of these blocks will be covered in more detail in later chapters.
Any application must do two things to start Angular:
- Load the angular.js library
Tell Angular which part of the DOM it should manage with the
Loading the Script
Using Google’s CDN is recommended. Google’s servers are fast, and the script is cacheable across applications. That is, if your user has multiple apps that use Angular, she’ll have to download it only 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
Declaring Angular’s Boundaries with ng-app
ng-app directive lets you tell Angular which part of your page it should expect to manage. If you’re building an all-Angular application, you should ...