我有一组复选框是从属组合。如果我选中一个选项框,则一个1或2个其他选项应该自动检查,反之亦然。
posixpath.join
由于出现错误而无法实现此目标 错误TypeError:values.forEach不是函数
答案 0 :(得分:0)
从此示例中汲取灵感
component.html
<mat-selection-list #access (selectionChange)="onSelection($event, access.selectedOptions.selected)" >
<mat-list-option *ngFor="let access of typesOfAccess" [value]='access' [selected]="access.checked">
{{access.name}}
</mat-list-option>
</mat-selection-list>
Component.ts
typesOfAccess = [{"name":"credit","checked":false},{"name":"sales","checked":true},{"name":"ops","checked":false},{"name":"bst","checked":false}];
onSelection(e, v) {
this.typesOfAccess[3].checked = !this.typesOfAccess[3].checked;
console.error(this.typesOfAccess[3].checked);
}
玩这个