我正在制作一个表格,这个表格有很多复选框,
我想获取复选框值,并将其设置为模型,
该模型将提交服务
这是我的代码
<form name="form" ng-submit="add()">
<dl>
<dt>Manager Id</dt>
<dd ng-repeat="user in User.user" >
<input name="userName[user.userId][]" type="checkbox"
ng- model="newProgram.program.managerId"
ng-true-value="{{user.userId}}" ng-false-value="{{user.userId}}" check />
{{user.userUsername}}
</dd>
<dt>Member Id</dt>
<dd ng-repeat="user in User.user">
<input name="userName[user.userId][]" type="checkbox"
ng-model="newProgram.program.memberId" value= "{{user.userId}}" check />
{{user.userUsername}}
</dd>
</dl>
<div class="form-actions">
<button type="submit"
ng-disabled="form_edit.$invalid || isUnchanged(newProgram)" >Add</button>
</div>
</form>
angular.module('elnApp')
.directive('check', function () {
return {
restrict: 'A',
require: 'ngModel',
link: function(scope, elm, attr, ngModelCtrl, $filter){
elm.bind('click', function() {
scope.$watch('newProgram.program.managerId', function (value){
// set {{user.userId}} to ngModel
}
});
});
}
}
});
angular.module('elnApp')
.controller('AddCtrl', function ($scope, programService, userService) {
$scope.master= {};
$scope.add = function () {
programService.add({
}, $scope.newProgram, function (data) {
$location.path('/grid');
});
};
$scope.isUnchanged = function(user) {
return angular.equals(user, $scope.master);
};
$scope.User= {'user': userService.query()};
});
我搜索了很多数据,但什么都没有???
请帮忙
多谢 !