Hearaman
Hearaman

Reputation: 8726

How to update scope model after operating the filters?

I'm trying to update the scope model ($scope.itemsCount) after operating the filters. Please have a look at my demo code which is similar to my original functionality.

Plnkr: http://plnkr.co/edit/grnCth?p=preview

I have used $watch to update the model but it didn't worked for me.

Please suggest a solution.

Required Functionality: Scope model should be updated. I'm not looking for expression some thing like to show the count.

             (item in items|myFilter:startFiltering).length;

Thank you in advance.

Upvotes: 1

Views: 833

Answers (1)

JB Nizet
JB Nizet

Reputation: 691943

You just need to call a function from your scope to get the item count. This function can use apply the same filter and get the length of the filtered array.

Here's an updated demo: http://plnkr.co/edit/5Z9lAvogqSAbVNJ6eQ89?p=preview

Upvotes: 3

Related Questions