I need an input value to be limited to [1, 5000000]. I want to do it programmatically. I am using AngularJS for my web application. Here is the code I wrote:
html
<input ng-change="checkLimit()" type="number" min="1" max="5000000" name="input" ng-model="data.flips" required/>
js
angular.module("app", []).controller("controller", function($scope) {
$scope.checkLimit = function() {
$scope.data.flips = $scope.data.flips > 5000000 ? 5000000 :
$scope.data.flips;
$scope.data.flips = $scope.data.flips < 1 ? 1 : $scope.data.flips;
}
});
I know for sure that the function runs, but the value in the input field and the variable is not updated. I am relatively new to Angular, so there is probably some elementary concept that I am missing.
$scope.data.flipsis?