Reputation: 11
I am using chrome.
This is my html code
ng-repeat="tag in formData.amenities"><label><input type="checkbox" ng-model="tag.enabled">{{tag.text}}:{{tag.enabled}}
I am able to collect tag values when I check/uncheck from the view. The problem is in reverse binding.
I am reading the values back and then applying to the above code. I can see that tag.enabled is set to true but the view doesnt show checked.
I have tried $scope.apply
but even that doesnt update the view.
Upvotes: 1
Views: 2655
Reputation: 18566
Use ng-checked
directive
<body ng-controller="MainController">
<div ng-repeat="tag in formData.amenities">
<label>Checkbox: <input type="checkbox" ng-checked="tag.enabled" ng-model="tag.enabled">{{tag.text}}:{{tag.enabled}}
</label>
</div>
</body>
In Controller:
angular.module("app", [])
.controller("MainController", function ($scope) {
$scope.formData = {
amenities: [{
"text": "First",
"enabled": true
}, {
"text": "second",
"enabled": false
}, {
"text": "Thid",
"enabled": true
}]
};
});
Upvotes: 1