2017-04-06 97 views
1

嗨我想检查复选框,如果用户选择视图复选框,它应该只选择视图复选框。如果用户选择编辑复选框,它应该同时选择视图和编辑复选框。这是一个plunker如何检查两个复选框同时在x可编辑使用角js

<td ng-click="profileform.$show()" align="center"> 
    <div> 
     <span e-ng-change="applyHighlight($data)" 
       editable-checkbox="Manage_Rolesui.View" 
       e-form="rowform" 
       ng-click="profileform.$show();"> 
      <input type="checkbox" 
        ng-model="Manage_Rolesui.View" 
        width="20"/> 
     </span> 
    </div> 
</td> 
<td ng-click="profileform.$show()" align="center"> 
    <span e-ng-change="applyHighlight($data)" 
      ng-checked="Manage_Rolesui.Edit" 
      editable-checkbox="Manage_Rolesui.Edit" 
      e-form="rowform" 
      ng-click="profileform.$show()"> 
     <input type="checkbox" 
       ng-model="Manage_Rolesui.Edit" 
       width="20"/> 
    </span> 
</td> 

回答

0

您可以使用ngChecked角指令自动检查查看时,编辑被选中是这样的:

<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" /> 

结帐的Official ngCheck documentation for more

或使用控制器

HTML

<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) 
    } 
}]); 

运行例如:https://plnkr.co/edit/Y79wezief0bndhah4hdF?p=preview

+0

是啊,我想到这个问题的解决方案,但是这并不能完全满足用户的要求,。如果您取消选择编辑,视图也会被取消选中。 – lin

+0

好的,我已经更新了我的答案以符合您的需求。 Pure Angular;) –

+0

不要把这样的逻辑放入视图m8。 – lin

相关问题