I\'m using ng-repeat to display a collection of values. My filter options changes according to an ajax call to server. How can I refresh the ng-repeat after the filter parameter
You need to tell angular that the values have changes:
$scope.loadNewFilter = function (){
$scope.filter = [1,2,3];
$scope.$apply();
}
You have placed
<button ng-click="loadNewFilter()"> filter now</button>
out of controller scope.
After receiving your filter called $scope.$apply() as following: It is refresh your scope.
$scope.$apply(function() {
// your code
});
In my case I had a trackBy in my ng-repeat and had to remove it to get it to update.
I didnt need to use $scope.apply() to see the update. What solved this error for me was to make sure: