<!doctype html>
<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.0/angular.min.js">
</script>
</head>
<body>
...
$ bower install angular
Then add a <script> to your index.html:
<script src="/bower_components/angular/angular.js"></script>
Extends the functionality of HTML
Directives are markers on a DOM element that attach behaviours. Essentially creates componentswhat HTML would have been, had it been designed for building web-apps
AngularJS docs
<!doctype html>
<html ng-app>
<head>
...
</head>
<body>
</body>
</html>
Directive
"Angularizes" the page
"Sets the scope for the page
<html ng-app>
<head></head>
<body ng-init="name='Nicolas Cage'">
<p> Hello, {{ name }} </p>
</body>
</html>
Directive
Expression
Modify output of directives and expressions
<html ng-app>
<head></head>
<body ng-init="name='Nicolas Cage'">
<p> Hello, {{ name | uppercase }} </p>
</body>
</html>
Filter
Automatic synchronization of data between the model and view components.
The view is a projection of the model at all times. When the model changes, the view reflects the change, and vice versa.
Angular DocsUsing a directive:
Of course, define your own directives and filters
Models ↔ Views ↔ Controllers
Connecting the parts together
$scope is the glue between the application controller and the view.
Reusable containers for different features of your app.
Anatomy of a module
Easily manage the modules, services, factories etc. that your controller needs
Angular data providers
Easy deep linking in single-page apps.
angular.module('myApp', ['ngRoute'])
.config(function ($routeProvider) {
$routeProvider
.when('/', {
template: 'partials/home.html',
})
.when('/about', {
template: 'partials/about.html',
})
.when('/contact', {
template: 'contact.html',
controller: 'contactCtrl'
})
.otherwise({
redirectTo: '/'
});
})
.controller('contactCtrl', function($scope) {
$scope.email = 'nicolas@cage.com';
...
});
Turtle's amazing first Angular app