Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular: what is filterFilter

Tags:

angularjs

i am new in angular and i am bit familiar with filter word but what is filterFilter word and usage in angular. just come across a code below from this url https://stackoverflow.com/a/22704140/6188148.

see the code

angular.module('FilterInControllerModule', []).
    controller('FilterController', ['filterFilter', function(filterFilter) {
      this.array = [
        {name: 'Tobias'},
        {name: 'Jeff'},
        {name: 'Brian'},
        {name: 'Igor'},
        {name: 'James'},
        {name: 'Brad'}
      ];
      this.filteredArray = filterFilter(this.array, {name:'Igor'});
    }]);

just tell me what is filterFilter ? is it any built-in filter ?

like image 484
Thomas Avatar asked Apr 18 '16 18:04

Thomas


Video Answer


1 Answers

Every filter can be injected as a service, whose name is <theNameOfTheFilter>Filter.

So, for example, if you want to use the uppercase filter from a controller (for example), you can do

module.controller('MyController', function($scope, uppercaseFilter) {
    $scope.foo = uppercaseFilter('hello');
});

Your code does the same thing, with the filter filter.

like image 56
JB Nizet Avatar answered Oct 27 '22 23:10

JB Nizet