【发布时间】:2017-09-25 06:10:00
【问题描述】:
我想使用 ng-repeat 访问复选框中的对象值(即规则名称拒绝、推迟、警告...),并且当对象中的值为“Y”时显示复选框为选中状态,当值为“N”时显示为未选中状态'
<div class="form-group">
<label class="checkbox-inline" ng-repeat="rules in savedRulesData ">
<input type="checkbox" id="checkBoxed" value="{{savedRulesData}}">{{rules}}
</label>
</div>
目前我的复选框显示如图所示。
我使用控制器中的 editRules 函数打开此模型
[http://tinypic.com/r/fog2gk/9]图片链接
$scope.editRules = function(ruleTypes,client) {
var obj=new Object();
var self=this;
var clientId=client.clientId;
var responsePromise = $http.get("typesofSavedRules/"+clientId);
responsePromise.success(function(data, status, headers, config) {
self.savedRulesData=data.objList;
$scope.savedRulesData=self.savedRulesData;
});
responsePromise.error(function(data, status, headers, config) {
alert("AJAX failed!");
});
modalInstance = $modal.open({
templateUrl: 'myModalContent.html',
scope: $scope,
size:'lg'
});
};
【问题讨论】:
-
savedRulesData的结构是什么?顺便说一句,您可以使用ng-true-valueandng-false-value -
这是一个你可以在图片链接@pro.mean中看到的对象
-
提示:一页必须有唯一的id。并在复选框中写
ng-model -
那个对象结构是什么?因为您正试图从对象中消耗值以使复选框成为选中/未选中的权利。?
-
在问题中粘贴对象结构
标签: javascript html angularjs checkbox