Slide 1

Slide 1 text

AngularJS Thierry Sans

Slide 2

Slide 2 text

Different approaches Binding between the DOM and the javascript code jQuery-like Using DOM selectors AngularJS Using Angular directives

Slide 3

Slide 3 text

Application

Slide 4

Slide 4 text

ng-app directive ... /index.html /app/simpsonsApp.json var app = angular.module('simpsonsApp',[]);

Slide 5

Slide 5 text

Controller

Slide 6

Slide 6 text

ng-controller directive

{{simpsons.title}}

/index.html /app/simpsonsApp.json app.controller('simpsonsController',function(){ this.data = “Hello World!”; this.foo = function(){ this.data = “The Simpsons”; }; )};

Slide 7

Slide 7 text

ng-show (ng-hide) directive

The Simpsons

...
/index.html /app/simpsonsApp.json app.controller('simpsonsController',function(){ show_form = false; this.toggle = function(){ this.show_form = ! this.show_form; }; )};

Slide 8

Slide 8 text

ng-repeat directive
“{{img.firstname}}"/
{{img.down_vote}}
{{img.up_vote}}
/index.html /app/simpsonsApp.json this.data = [ {"firstname": “Bart", ...}, {"firstname": “Lisa”, ...} ];

Slide 9

Slide 9 text

Forms

Slide 10

Slide 10 text

ng-model and ng-submit directive /app/simpsonsApp.json app.controller('simpsonsController',function($scope){ this.character = {}; this.add_simpson = function(){ this.character.up_vote=0; this.character.down_vote=0; this.data.push(this.character); this.character = {}; $scope.add_simpson_form.$setPristine(); };});
Add a Simpson
/index.html

Slide 11

Slide 11 text

Ajax

Slide 12

Slide 12 text

$ajax /app/simpsonsApp.json app.controller('simpsonsController',function($http){ this.data = []; var controller = this; $http.get('api/simpsons.json') .success(function(data,status){ controller.data = data; }) .error(function(error,status){ }); });

Slide 13

Slide 13 text

Service (Model)

Slide 14

Slide 14 text

Routing