F
F
First name Last name2015-11-16 16:08:16
Angular
First name Last name, 2015-11-16 16:08:16

How to get the value of a checkbox in angular?

<div class="checkbox">
          <label>
            <input type="checkbox" ng-model="ch1" value="10000"> Услуга 1
          </label>
        </div>
        <div class="checkbox">
            <label>
              <input type="checkbox" ng-model="ch2" value="10000"> Услуга 2
            </label>
        </div>
      

    <span>Стоимость услуг составила: </span><span>{{ch1 + ch2}}</span>

It is necessary that the sum of the value checkboxes be displayed in the span. But in response to change, a true value (that is, 1) is displayed, and 1 + 1 is summed up.
What am I doing wrong?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
L
lega, 2015-11-16
@nickname-none

ng-true-value="10000" ng-false-value="0"

S
Sergey, 2015-11-16
Protko @Fesor

read documentation https://docs.angularjs.org/api/ng/input/input%5Bch...

A
Andrew, 2015-11-16
@R0dger

Through ng-change, do everything .. into a separate variable and that's it .... and there will be happiness ..
https://docs.angularjs.org/api/ng/directive/ngChange

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question