Is there a way to use AngularJS to dynamically limit user input to numbers between 0 and 1 with hundredths? For instance, if a user types 0, it should be converted to 0.00; if they type 1, it should become 1.00. I already have a JavaScript function for limiting user input, but I would like to make it dynamic with AngularJS.
var myApp = angular.module('myApp', []);
myApp.controller('CalcCtrl', function ($scope) {
var num = 0.0;
$scope.qty = new Quantity();
$scope.num = num;
});
function Quantity(numOfPcs) {
var qty = numOfPcs;
this.__defineGetter__("qty", function () {
return qty;
});
this.__defineSetter__("qty", function (val) {
val = parseFloat(val);
qty = val;
});
}