-1

I want to get some attr's value in a checkbox when it is checked,is there any directive for it?

Potato Running
  • 408
  • 4
  • 11

2 Answers2

1

use the native ng-model:

<input type="checkbox" ng-model="valid"/>

and in your controller:

 $scope.valid //true or false
Diego Polido Santana
  • 1,425
  • 11
  • 19
0

The attributes are ng-true-value and ng-false-value.

<input type="checkbox" ng-model="box" ng-true-value="'yes'" ng-false-value="'no'">

In the above example the variable $scope.box will be set to 'yes' when the box is checked; 'no' when unchecked.

For more information, see AngularJS input[checkbox] Directive API Reference.

georgeawg
  • 48,608
  • 13
  • 72
  • 95