Q:

AngularJS apply filter in javascript instead of html

I have a ng-repeat to create table:
ng-repeat="equipment in equipments | filter: equipmentFilter | dateFilter: dateStart: dateEnd | pageFilter: currentPage * pageSize | limitTo: pageSize"

I need to get:
(equipments | dateFilter: dateStart: dateEnd | filter: equipmentFilter).length

to update number of total page in paging feature. I've tried:
ng-init="equipmentsForPaging = (equipments | dateFilter: dateStart: dateEnd | filter: equipmentFilter)"

But it isn't working at all, also I don't think using ng-init is a good idea. So are there anyway to do this in javascript?

A:

There are $filter, you can inject and use it in your controller.
But if you use that, you will re use filter so there are 2 filter treatments (2 loops) so in my opinion it's not good idea.
You already got that filtered array in your view, you just need to assign it to a variable, in the ng-repeat, and use parenthesis to distinct your needed array:
ng-repeat="equipment in filtered = (equipments | filter: equipmentFilter | dateFilter: dateStart: dateEnd) | pageFilter: currentPage * pageSize | limitTo: pageSize"
then you can just use {{filtered.length}}

