Reputation: 545
On page load i am checking if attestationStatus flag is approved i want to make check box checked , with below implementation its not working, Any idea what implemented wrong.
main.html
<div class="col-md-3">
<label class="radio-inline">
<input type="checkbox"
ng-model="aprv"
name="attestorFlag"
id="attestorFlag"
ng-value="'Y'"> I attest
</label>
</div>
main.js
if ($scope.attestorObj.attestationStatus === 'approved') {
$scope.aprv = 'Y';
}
Upvotes: 0
Views: 11599
Reputation: 3765
you could add the condition to your checkbox itself by adding the ng-checked. think this should work for you, hope this helps or gets you in the right direction
<div class="col-md-3">
<label class="radio-inline">
<input type="checkbox"
ng-checked="$scope.attestorObj.attestationStatus == 'approved'"
ng-model="aprv"
name="attestorFlag" id="attestorFlag"> I attest </label>
</div>
Upvotes: 1
Reputation: 5760
You don't need ng-value
. Use only ng-model
and set the $scope.aprv
value to true
or false
.
<input type="checkbox" ng-model="aprv" name="attestorFlag" id="attestorFlag">
Controller:
if ($scope.attestorObj.attestationStatus === 'approved') {
$scope.aprv = true;
}
http://codepen.io/ces/pen/gpexBX
Upvotes: 5