On Github lauterry / slides-prez-angular-filters
presenté par LAU Thierry - @laut3rry
hello
HELLO
1368730200
Jeudi 16 mai 2013 20H50
1234.562342
1 234,56 €
[Thierry, David, Nelly, Alex, Claire]
[Alex, Claire, David, Nelly, Thierry]
[pommes, pâtes, farine, PQ]
[PQ]
$scope.amount = 1234.56;
<div>{{amount}}</div> <!-- 1234.56 -->
<div>{{amount | currency}}</div> <!-- $1,234.56 -->
<div>{{amount | currency:"USD$"}}</div> <!-- USD$1,234.56 -->
<html ng-app="myModule"> <div>{{name | greet}}</div> <!-- Yo Thierry --> </html>
angular.module("myModule") .filter('greet', function (dep1, dep2, ...) { });
<html ng-app="myModule"> <div>{{name | greet}}</div> <!-- Yo Thierry --> </html>
angular.module("myModule") .filter('greet', function (dep1, dep2, ...) { return function(value) { return 'Yo ' + value; }; });
<html ng-app="myModule"> <div>{{name | greet:true}}</div> <!-- Bonjour Thierry --> </html>
angular.module("myModule") .filter('greet', function (dep1, dep2, ...) { return function(value, isPolite) { if(isPolite){ return 'Bonjour ' + value; } else { return 'Yo ' + value; } }; });
function myController($scope, greetFilter){ };
Declarative
Pas de manipulation de DOM
twitter : @laut3rry
google + : gplus.to/lauthierry