Javascript 如何使用angular js在x-editable中同时选中这两个复选框
嗨,我想勾选该复选框,如果用户选中查看复选框,则应选中仅查看复选框。如果用户选择编辑复选框,则应同时选择查看和编辑复选框。这是一本书Javascript 如何使用angular js在x-editable中同时选中这两个复选框,javascript,jquery,angularjs,mean-stack,x-editable,Javascript,Jquery,Angularjs,Mean Stack,X Editable,嗨,我想勾选该复选框,如果用户选中查看复选框,则应选中仅查看复选框。如果用户选择编辑复选框,则应同时选择查看和编辑复选框。这是一本书 您可以使用ngCheckedangular指令在以这种方式选中编辑时自动检查视图: <input type="checkbox" ng-model="Manage_Rolesui.View" width="20" /> <input type="checkbox" ng-model="Manage_Rolesui.Edit" ng-change
您可以使用
ngChecked
angular指令在以这种方式选中编辑时自动检查视图:
<input type="checkbox" ng-model="Manage_Rolesui.View" width="20" />
<input type="checkbox" ng-model="Manage_Rolesui.Edit" ng-change="Manage_Rolesui.View = (Manage_Rolesui.Edit === true)" width="20" />
运行示例:您可以使用
ngChecked
angular指令在以这种方式选中编辑时自动检查视图:
<input type="checkbox" ng-model="Manage_Rolesui.View" width="20" />
<input type="checkbox" ng-model="Manage_Rolesui.Edit" ng-change="Manage_Rolesui.View = (Manage_Rolesui.Edit === true)" width="20" />
运行示例:是的,我考虑过这个解决方案,但它并不完全符合用户的要求。如果您取消选中
edit
,视图也会取消选中edit
。好的,我已经更新了我的答案以满足您的需要。纯角度;)不要将这样的逻辑放到视图m8中。这是最简单的方法,但也可以使用控制器方法;)更新了我的答案,该死!你说得对!在我的帖子中,我从一个无控制器的解决方案开始,以一个非常接近你的代码结束!我们都应该得到一枚奖牌^^^是的,我考虑过这个解决方案,但这并不完全符合用户的要求。如果您取消选中edit
,视图也会取消选中edit
。好的,我已经更新了我的答案以满足您的需要。纯角度;)不要将这样的逻辑放到视图m8中。这是最简单的方法,但也可以使用控制器方法;)更新了我的答案,该死!你说得对!在我的帖子中,我从一个无控制器的解决方案开始,以一个非常接近你的代码结束!我们都应该得到一枚奖章^^
<div ng-controller="ExampleController">
<label>View</label>
<input type="checkbox" ng-model="Manage_Rolesui.View" width="20" />
<label>Edit</label>
<input type="checkbox" ng-model="Manage_Rolesui.Edit" ng-change="autoCheckView()" width="20" />
</div>
angular.module('app', []);
angular.module('app')
.controller('ExampleController', ['$scope', function($scope) {
$scope.autoCheckView = function() {
$scope.Manage_Rolesui.View = ($scope.Manage_Rolesui.Edit === true)
}
}]);