Getting an App running with Angular is fairly simple. Like all JavaScript libraries you will need to link to it with a script tag. After that add “ng-app” as an attribute to any tag besides head. Here, at the time of publishing, is a working example:
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.14/angular.min.js"></script> <title>JS Bin</title> </head> <body ng-app ng-init="imperative = 'should';"> These two lines should look identical. <br/> These two lines {{imperative}} look identical. </body> </html>
Live example: http://jsbin.com/xufal/latest/edit
That’s it! that is all. So the recipe for an Angular app is:
- A link to the library.
- An ng-app tag on a element in the page.
The attribute ng-app tells the library where the app will start. Here it is body but it could have been on the html tag. The thing to note is that what ever you want angular to be able to “see” needs to be either in the tag you placed ng-app on or a child element.