Faizuddin Mohammed
Faizuddin Mohammed

Reputation: 4328

How to find the length of array returned by the 'filter' filter of AngularJS?

I am using the 'filter' filter of AngularJS like this:

<li ng-repeat='item in items | filter: searchTerm'></li>

Now, how do I find out the length of array returned by the filter?

Thanks in advance

Upvotes: 0

Views: 104

Answers (3)

Razvan B.
Razvan B.

Reputation: 6771

Or, a more simple solution:

<li ng-repeat='item in filtered = (items | filter: searchText)'></li>

Then:

{{filtered.length}}

Upvotes: 1

RIYAJ KHAN
RIYAJ KHAN

Reputation: 15290

check this one

<li ng-repeat='item in ($parent.filterR=(items | filter: searchTerm))' >
</li>

{{filterR.length}}

Upvotes: 1

Shubham Nigam
Shubham Nigam

Reputation: 3954

HTML

<li ng-repeat='item in items | filter: searchTerm' check>
</li>

Directive

 app.directive('check',function(){
    return {
            restrict: 'A',

        link: function (scope, el, attrs) {
        if(scope.$last){
       alert(scope.$index+1);//count value
       }
    }
});

I hope this will help you

Upvotes: 0

Related Questions