Below is my controller. I want to convert 'form.paymentmade+ newpayment' to numbers; presently the values are just concatenating as strings.
Say if the value of form.paymentmade = 3 and then I entered newpayment = 45, the result=34555555555. I guessed it's because both have not been parsed as int.
<script>
function TodoCtrl ($scope) {
$scope.$watch ('form.paymentmade + newpayment' , function (value) {
$scope.form.paymentmade = value;
});
}
</script>
Here's what I tried, but it's not working:
<script>
function TodoCtrl ($scope) {
$scope.$watch (parseInt(form.paymentmade ) + parseInt (newpayment), function (value) {
$scope.form.paymentmade = value;
});
}
</script>
How do I parse to int and sum in angularjs?