javascript - Run $scope function when input field modifies? -
javascript - Run $scope function when input field modifies? -
i have input field, can specify min number of reviews. have function updates info ng-repeat
populates , create table. need is, when type number input field function of mine, runs automatically , changes info means table up-to-date automatically. sort of two-way binding. (i don't want utilize filter straight on ng-repeat
, filters in angular run , decrease performance)
here 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 ng-repeat
:
ng-repeat="car in sortedcarlist"
and here function:
$scope.formattedtable = function(index){ $scope.initcarlist(index); $scope.sortedcarlist = []; var carlistlength = $scope.carlist.length; (var i=0;i<carlistlength;i++){ // checks every row if values passes user requirements like: min number of review , cost range var rowbool = $scope.tablefilter($scope.carlist[i]); if (rowbool){ $scope.sortedcarlist.push($scope.carlist[i]); } } }
how can accomplish this?
use ng-change
directive run specific function every time input changes.
<label>reviews min: <input type="number" ng-init="revnum=30" class="form-control review-input" min="0" step="10" ng-model="filtervalues.revnum" ng-change="formattedtable()" /></label>
javascript html angularjs
Comments
Post a Comment