Created
November 24, 2014 13:55
-
-
Save EmmanuelDemey/14e45c646d3823778148 to your computer and use it in GitHub Desktop.
Slide 136 - Let's use Angular Filters!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <div data-ng-controller="FilterCtrl"> | |
| Filter: <input type="text" data-ng-model="filterName"/> | |
| / Show <input type="text" data-ng-model="nbResults"/> results | |
| <table> | |
| <tr> | |
| <th><a href="">Name</a></th> | |
| <th><a href="">Phone</a></th> | |
| <th><a href="">Age</a></th> | |
| <th><a href="">Money</a></th> | |
| <th><a href="">Birth Date</a></th> | |
| </tr> | |
| <tr data-ng-repeat="user in users | filter:filterName | limitTo:nbResults "> | |
| <td>{{user.name}}</td> | |
| <td>{{user.phone}}</td> | |
| <td>{{user.age}}</td> | |
| <td>{{user.money}}</td> | |
| <td>{{user.date}}</td> | |
| </tr> | |
| </table> | |
| </div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var FilterCtrl = function($scope) { | |
| $scope.users = [ | |
| {name:'Bob', phone:'1212', age:10, money: 25, date: '1288323623006'}, | |
| {name:'Bill', phone:'9876', age:19, money: 43, date: '1285324523606'}, | |
| {name:'Mike', phone:'5678', age:35, money: 80, date: '1288323854123'}, | |
| {name:'Adam', phone:'8765', age:29, money: 0, date: '1288329412539'} | |
| ]; | |
| $scope.predicate = 'name'; | |
| $scope.nbResults = 10; | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment