Reputation: 21
<div ng-app="myApp" ng-controller="myCtrl">
First Number: <input type="text" ng-model="firstNum"><br>
Last Number: <input type="text" ng-model="lastNum"><br>
<br>
Result: {{firstNum + lastNum}}
</div>
I have problem adding, because concatenate both built-in numbers but not adding, Also, when the input is empty I get NULL.
Check other post, And I do not know why it does not come to me.
Here is an image.. enter image description here
I have my application in phalcon and change the estructure Angular:
myApp.config(function($interpolateProvider) {
$interpolateProvider.startSymbol('[[');
$interpolateProvider.endSymbol(']]');
});
To discard the angular version, remove it from my application and try with Angular [v1.5.5 and v1.6.2] and pure HTML and it works fine.
But in my application that works with phalcon, AngularJS I also use the ui-bootstrap-tpls-0.12.0.min.js, because the addition process I do in the modal,I guess some conflict is going on with ui-bootstrap-tpls-0.12.0.min.js, Because there comes the problem, It does not sum up well and It doesn't add up well.
These are the scripts I use in my application : script of my app
I do not know how to solve it, some help would be important.
Upvotes: 0
Views: 78
Reputation: 5841
Try this :
{{firstNum.toString() + lastNum.toString()}}
toString() will solve the "null" text things, and also concat function with +
Upvotes: 0
Reputation: 21
Change from type="text" to type="number" (HTML5) Try following code
type="number"
or you can keep html as it is Try following code (change just expression)
Result: {{(firstNum - 0) + (lastNum - 0)}}
Upvotes: 0
Reputation: 4787
I tried your code in a Plunker, it works well !
I used Angular 1.5.5 & the last 1.6.2, didn't get this NULL
You may assign default values for you ng-model ?
Plunker link : http://plnkr.co/edit/Z14d8wCNjhY8ht7TwQhB?p=preview
Check it and tell me if script.js
is different than yours, but I can tell you it's well working.
Upvotes: 0