I'm applying a greater than filter to a ng-repeat tag. I wrote the following custom filter function:
$scope.priceRangeFilter = function (location) {
return location.price >= $scope.minPrice;
};
and I use it in the following HTML code:
<div ng-repeat="m in map.markers | filter:priceRangeFilter">
What is the best way to trigger a refresh of the ng-repeat tag when $scope.minPrice is updated?
It should be automatic. When
$scope.minPrice
is changed, the repeater will be automatically updated.Demo on jsFiddle
Create the filter as a filter service using the angularjs filter api, and add minPrice as a parameter.
and in the template
See an example in this fiddle: http://jsfiddle.net/Zmetser/BNNSp/1/