javascript - Angularjs: greater than filter with ng-repeat -
i'm applying greater filter ng-repeat tag. wrote following custom filter function:
$scope.pricerangefilter = function (location) { return location.price >= $scope.minprice; };
and use in following html code:
<div ng-repeat="m in map.markers | filter:pricerangefilter">
what best way trigger refresh of ng-repeat tag when $scope.minprice updated?
it should automatic. when $scope.minprice
changed, repeater automatically updated.
function ctrl($scope, $timeout) { $scope.map = [{ name: 'map1', price: 1 }, { name: 'map2', price: 2 }, { name: 'map3', price: 3 }]; $scope.minprice = 0; $scope.pricerangefilter = function (location) { return location.price >= $scope.minprice; }; $timeout(function () { $scope.minprice = 1.5; }, 2000); }
Comments
Post a Comment