1

如果我将开关按钮的值更改为 false ,则将所有子模块的值更改为 false

<div class="content">
  <md-slide-toggle color="primary" [(ngModel)]="permission.permission.department.main" [ngModelOptions]="{standalone: true}">On/Off</md-slide-toggle>
</div>
<div *ngIf="permission.permission.department.main" class="content">
    <md-checkbox [(ngModel)]="permission.permission.department.view" align="end" [ngModelOptions]="{standalone: true}">View</md-checkbox>
    <md-checkbox [(ngModel)]="permission.permission.department.add" align="end" [ngModelOptions]="{standalone: true}">Add</md-checkbox>
    <md-checkbox [(ngModel)]="permission.permission.department.edit" align="end" [ngModelOptions]="{standalone: true}">Edit</md-checkbox>
    <md-checkbox [(ngModel)]="permission.permission.department.delete" align="end" [ngModelOptions]="{standalone: true}">Delete</md-checkbox>    
</div>
4

1 回答 1

0

您可以更新更改功能的值,请检查并让我知道您是否需要其他内容

<md-slide-toggle color="primary" 
[(ngModel)]="permission.permission.department.main" 
(change)="setValue(permission.permission.department.main,permission.permission.department)" 
[ngModelOptions]="{standalone: true}">On/Off</md-slide-toggle>

在你的 ts 文件中添加一个方法

setValue(currentvalue,p){
for (var key in p) {
  if (p.hasOwnProperty(key)) {
    p[key]=currentvalue;
  }
}
}
于 2016-12-09T11:42:22.753 回答