Answer the question
In order to leave comments, you need to log in
How to generate sum using AngularJS?
Started learning AngularJS. I want to start with a simple example. On sites, acquaintance begins with more complex examples, tell me how to do a simple thing:
There is a form with fields on it:
<input ng-model="Price" id="Price" name="Price" type="hidden" value="1500" />
Цена: {{Price}}<br />
Количество: <input ng-model="Count" id="Count" name="Count" type="text" value="0" /><br />
Сумма: {{Count * Price}} руб<input id="Amount" name="Amount" type="hidden" value="0" /><br />
Answer the question
In order to leave comments, you need to log in
You can set values through ng-init="Price=1500", Amount can be "beaten" in several ways, if without a controller, then you can try ng-model for Amount and update it on an ng-change (or ng-keyup) event to do the calculation : ng-change="Amount=Price*Count"
Here's an Angular Light example: jsfiddle.net/lega911/f66ep40p
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question