0

I am wanting to know: how does one get a DEFAULT value for the ng-model inside a CHECKBOX to be true? The code i have will check the box but whenever i evaluate the model it keeps saying UNDEFINED...why is that?

           <input ng-change="docModel.check()"
                                    type="checkbox"
                                    ng-model="amountSelected" 
                                    ng-checked="true" />
user1789573
  • 515
  • 2
  • 8
  • 23
  • possible duplicate of [AngularJS - Value attribute on an input text box is ignored when there is a ng-model used?](http://stackoverflow.com/questions/10610282/angularjs-value-attribute-on-an-input-text-box-is-ignored-when-there-is-a-ng-m) – Blackhole Jan 07 '15 at 20:17

2 Answers2

2

To define the default value when using AngularJS, simply give a value to the model variable in your controller:

$scope.amountSelected = true;
Blackhole
  • 20,129
  • 7
  • 70
  • 68
0

According the officiel AngularJS documentation ngChecked directive:

Note that this directive should not be used together with ngModel, as this can lead to unexpected behavior

link to the doc