10. DATABINDING / DIGEST EXAMPLE
<inputtype="text"ng-model="title"/>
<spanng-bind="title"></span>
1. User add a character in the text box
2. The keydown event triggers the digest cycle
3. ng‐model modifies the $scope.title
4. $scope.title modifies ng‐bind
5. at least one value is updated: restart digest
6. nothing is updated: no more digest.
15. EMBED DATA IN A CONTROLLER
The controller binds variables between JavaScript and HTML.
<divng-controller="MyController">
<spanng-bind="myText"></span>
<buttonng-click="valid()">ValidMe!</button>
</div>
The $scope transports variables.
angular.module('app').controller('MyController',MyController);
functionMyController($scope){
$scope.myText='Iamthebest';
$scope.valid=function(){alert($scope.myText);};
}
42. TUTORIAL / GET THE PROJECT
GET THE PROJECT
$gitclonehttps://github.com/fabienvauchelles/stweb-angularjs-tutorial.git
$cdstweb-angularjs-tutorial/frontend
43. TUTORIAL / CREATE THE MAIN APP
GET THE NEXT STEP
$gitreset--hardq0
$npminstall
$bowerinstall
$gulpserve
WORK
1. Create the app in src/app/index.js
2. Add ng‐app to the html tag (src/app/index.html)
44. TUTORIAL / FIRST CONTROLLER
GET THE NEXT STEP
$gitreset--hardq1
$gulpserve
WORK
1. Add controller AppController in index.js
2. Reference controller on body tag (index.html)
45. TUTORIAL / NG-REPEAT
GET THE NEXT STEP
$gitreset--hardq2
$gulpserve
WORK
1. Use ng‐repeat to show many articles
2. Fill every field of an article with ng‐bind
3. Use ng‐repeat to show many tags of articles
46. TUTORIAL / FILTER
GET THE NEXT STEP
$gitreset--hardq3
$gulpserve
WORK
1. Add search field searchText with ng‐model to the input
(search bar)
2. Filter ng‐repeat with filter:searchText
WORK (BONUS)