I have an input field, where you can specify min number of reviews. I also have a function that updates data that ng-repeat populates and create the table. But what I need is, when you type some number into input field this function of mine, runs automatically and changes data which means that my table is up-to-date automatically. It is some sort of two-way binding. (I don't want to use filter directly on my ng-repeat, filters in angular run very frequently and decrease performance)
Here is my input field:
<label>Reviews Min: <input type="number" ng-init="revNum=30" class="form-control review-input" min="0" step="10" ng-model="filterValues.revNum" /></label>
Here is my ng-repeat:
ng-repeat="car in sortedCarList"
And here is the function:
$scope.formattedTable = function(index){
$scope.initCarList(index);
$scope.sortedCarList = [];
var carlistLength = $scope.carList.length;
for (var i=0;i<carlistLength;i++){ // just checks every row if values passes user requirements like: min number of review and price range
var rowBool = $scope.tableFilter($scope.carList[i]);
if (rowBool){
$scope.sortedCarList.push($scope.carList[i]);
}
}
}
How can I achieve this?
ng-change?