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
我有一些复选框,它们在数据库中的值是'Y'或'N'作为枚举。为了进行更新我必须检查所有复选框。如何查看复选框已选中。这是复选框的代码
<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)">
2 个解决方案
#1
16
Use ng-checked
for check-boxes,
使用ng-checked复选框,
<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>
#2
0
The model newItem.have_voter_id
and newItem.have_passport
is set to true
or false
according to your action on the checkbox. If the checkbox of 'voter_id' is checked then the value of the model newItem.have_voter_id
will be updated to true
and if unchecked the value will be updated to false
. And the same goes for the other checkbox.
根据您对复选框的操作,模型newItem.have_voter_id和newItem.have_passport设置为true或false。如果选中“voter_id”复选框,则模型newItem.have_voter_id的值将更新为true,如果未选中,则值将更新为false。另一个复选框也是如此。
#1
16
Use ng-checked
for check-boxes,
使用ng-checked复选框,
<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>
#2
0
The model newItem.have_voter_id
and newItem.have_passport
is set to true
or false
according to your action on the checkbox. If the checkbox of 'voter_id' is checked then the value of the model newItem.have_voter_id
will be updated to true
and if unchecked the value will be updated to false
. And the same goes for the other checkbox.
根据您对复选框的操作,模型newItem.have_voter_id和newItem.have_passport设置为true或false。如果选中“voter_id”复选框,则模型newItem.have_voter_id的值将更新为true,如果未选中,则值将更新为false。另一个复选框也是如此。