formations/javascript/angular/filtres-2.md
2015-04-09 23:11:56 +02:00

17 lines
397 B
Markdown

# .cadoles-slide-title[Les filtres (2/3)]
**Exemple d'usage dans un contrôleur**
```js
angular.module('myApp', [])
.controller('MyCtrl', ['$scope', '$filter', function($scope, $filter) {
var myArr = ['item 1', 'item 2', 'item 3'];
// Usage: result = $filter(filterId, input, arg1, arg2, ...);
console.log( $filter('limitTo', myArr, 2) ); // -> ['item 1', 'item 2']
}])
;
```