How to reference filtered ng-repeat items from a controller in AngularJS
Posted
by
ParkerDigital
on Stack Overflow
See other posts from Stack Overflow
or by ParkerDigital
Published on 2013-05-28T13:44:24Z
Indexed on
2013/06/26
22:22 UTC
Read the original article
Hit count: 127
angularjs
I have some JSON data that is rendered out via the ng-repeat directive, and the results are then filtered via some checkboxes/drop-downs, and some custom filter functions in my controller.
I now want to add a function to my controller that is triggered by an 'ng-change' on some of the checkboxes, that can reference the current list of items in my 'ng-repeat'. I realise I can reference these values from a custom filter, for example $scope.filterProvider = function(item)
, but this function is then called for each and every item in the ng-repeat, which isn't what I want - I want the function to just be called each time a checkbox is checked/unchecked, and I need that function to be able to reference the items in my ng-repeat...does that make sense to anyone?! And if so, does anyone know how I can do that?
Thanks :-)
© Stack Overflow or respective owner