@@ -32,10 +32,13 @@ E.g. the markup `{{ 1234 | number:2 }}` formats the number 1234 with 2 decimal p
3232
3333## Using filters in controllers, services, and directives
3434
35- You can also use filters in controllers, services, and directives. For this, inject a dependency
36- with the name `<filterName>Filter` to your controller/service/directive. E.g. using the dependency
37- `numberFilter` will inject the number filter. The injected argument is a function that takes the
38- value to format as first argument and filter parameters starting with the second argument.
35+ You can also use filters in controllers, services, and directives.
36+
37+ <div class="alert alert-info">
38+ For this, inject a dependency with the name `<filterName>Filter` into your controller/service/directive.
39+ E.g. a filter called `number` is injected by using the dependency `numberFilter`. The injected argument
40+ is a function that takes the value to format as first argument, and filter parameters starting with the second argument.
41+ </div>
3942
4043The example below uses the filter called {@link ng.filter:filter `filter`}.
4144This filter reduces arrays into sub arrays based on
@@ -108,6 +111,7 @@ text upper-case.
108111 No filter: {{greeting}}<br>
109112 Reverse: {{greeting|reverse}}<br>
110113 Reverse + uppercase: {{greeting|reverse:true}}<br>
114+ Reverse, filtered in controller: {{filteredGreeting}}<br>
111115 </div>
112116 </file>
113117
@@ -127,8 +131,9 @@ text upper-case.
127131 return out;
128132 };
129133 })
130- .controller('MyController', ['$scope', function($scope) {
134+ .controller('MyController', ['$scope', 'reverseFilter', function($scope, reverseFilter ) {
131135 $scope.greeting = 'hello';
136+ $scope.filteredGreeting = reverseFilter($scope.greeting);
132137 }]);
133138 </file>
134139</example>
0 commit comments