Set checkboxes as checked using angularjs

angularjs, angularjs-directive, angularjs-scope

Solution

Use `ng-checked` for check-boxes,

<label class="radio-inline">
  <input type="checkbox"  ng-model="newItem.have_voter_id"  value="have_voter_id" ng-checked="newItem.have_voter_id=='Y'"/><?php echo $this->lang->line('label_voter_id'); ?>
</label>

<label class="radio-inline">
  <input type="checkbox"   ng-model="newItem.have_passport" value="passport" ng-checked="newItem.have_passport=='Y'"/> <?php echo $this->lang->line('label_passport'); ?>
</label>

Problem

I have some checkboxes and their value is in database are 'Y' or 'N' as enum.for making updation i have to review all the checkboxes.how to view checkboxes as checked. this is code for checkboxes ``` <label class="radio-inline"> <input type="checkbox" ng-model="newItem.have_voter_id" value="have_voter_id" /><?php echo $this->lang->line('label_voter_id'); ?> </label> <label class="radio-inline"> <input type="checkbox" ng-model="newItem.have_passport" value="passport" /> <?php echo $this->lang->line('label_passport'); ?> </label> ``` and this is the function for view and updation ``` $scope.edit = function(id,family_id) { $scope.action = 'update'; FamilyMem.get({id:id,family_id:family_id}, function (response) { // success $scope.newItem = response.data; // store result to variable $("#myModal").modal('show'); }, function (error) { // ajax loading error Data.errorMsg(); // display error notification //$scope.edit = false; }); }; ``` and edit button ``` <a href="" class="btn btn-magenta btn-sm" ng-click="edit(family_member.id,family_member.family_id)"> ```

Original source