Reputation: 789
In html
<input type="number" min="0" max="1000" class="form-control" ng-model="eachvalue.hours" ng-change="updateHour(eachvalue);" placeholder="Hours" required>
In Controller
$scope.updateHour = function (val) {
console.log(val);
}
I m not getting the value of 10.100 on controller when changing the number text box , here i can only console the value of 10.1
Can anyone know how to resolve the issue ?????????
Upvotes: 0
Views: 66
Reputation: 1022
You could try to define eachvalue.hours like that so you can bind to it:
$scope.eachvalue = { hours: 0 };
Upvotes: 0
Reputation: 2962
you can change your HTML also instaed
ng-change="updateHour(eachvalue)
TO
ng-change="updateHour(eachvalue.hours)
Upvotes: 0
Reputation: 5013
By using ng-model
, the value is already (two-way-)bound to $scope.eachvalue.hours
. It will always be up-to-date, no need to use ng-change and pass a value to it.
$scope.updateHour = function () {
console.log($scope.eachvalue.hours);
}
Upvotes: 1