I want to use angular to make an automatic adder, the code is as follows
<input type="text" ng-model="add1">
<input type="text" ng-model="add2">
<p>total={{add1+add2}}</p>
This code simply connects strings. I tried to use parseInt(add1) parseInt(add2) but it didn’t work. I don’t know if Angular has any method to convert characters into numerical values.
阿神2017-05-15 16:53:59
You can add the corresponding function in $scope
$scope.parseInt = parseInt;
Then you can use it
parseInt(add1) + parseInt(add2)