Solution 1 – Using Double Negation
Very beautiful hack. Code as…
<div ng-app="">
<h3>Using Double Negation</h3>
<p>First Number:
<input type="text" ng-model="a" />
</p>
<p>Second Number:
<input type="text" ng-model="b" />
</p>
<p>Sum: {{ a -- b }}</p>
</div>
Solution 2 – Using HTML5 Input Type Number
<div ng-app="">
<h3>Using Input Type Number</h3>
<p>First Number:
<input type="number" ng-model="x" />
</p>
<p>Second Number:
<input type="number" ng-model="y" />
</p>
<p>Sum: {{ x + y }}</p>
</div>
No comments:
Post a Comment