此处当我仅选中复选框时,选中的复选框值将使用之前的值更新,否则不会使用之前的值更新。尽管检查了复选框,但它什么也没添加。我正在使用SharePoint并使用rest API。 这是我的html
<div class="form-group" ng-repeat = "option in beftnBranchChecker track by $index">
<div class="checkerMakerLabel">
<label><input type="checkbox" ng-value="option" ng-checked="{{resultForBEFTNBranchChecker[$index]}}" ng-model="UpdateBEFTNBranchChecker[option]">{{option}}</label>
</div>
这是我的控制器代码
var UpdateBEFTNBranchCheck = [];
angular.forEach($scope.UpdateBEFTNBranchChecker, function (selected,option) {
if(selected){
UpdateBEFTNBranchCheck.push(option);
}
});
newUserAccessSvc.updateUserBeftn(UpdateBEFTNBranchCheck)
.then(function () {
newUserAccessSvc.closeLoading();
alert("User BEFTN Update request has been submitted successfully.");
}, function (error) {
newUserAccessSvc.closeLoading();
alert("Error occurred in User BEFTN.");
});
这是我的服务代码
function updateUserBeftn(beftnBranchCheck) {
var data = {
"__metadata": {
"type": "SP.Data.UsersBEFTNListItem"
},
"BranchCheckerInward" : {
"results" : beftnBranchCheck
}
};
var url = "/_api/web/lists/GetByTitle('Users BEFTN')/GetItemById(" + userBEFTN.id + ")";
return spBaseService.updateRequest(data, url);
}
答案 0 :(得分:0)
<div class="form-group" ng-repeat = "option in beftnBranchChecker track by $index">
<div class="checkerMakerLabel">
<label>
<input type="checkbox"
ng-value="option.Value"
ng-checked="option.IsbeftnBranchChecked"
ng-model="option.IsbeftnBranchSelected">{{option}}
</label>
</div>