【发布时间】:2019-08-24 01:27:15
【问题描述】:
我有来自服务的组列表,并为所有组创建多项选择列表。
每个组都有一个模板列表,就像数组中的数组一样。
我的代码
<mat-expansion-panel *ngFor="let group of groups">
<mat-expansion-panel-header>
<mat-panel-title>
{{group.name}}
</mat-panel-title>
</mat-expansion-panel-header>
<mat-selection-list role="list"
[(ngModel)]="selectedTemplates"
[ngModelOptions]="{standalone: true}"
(selectionChange)="checkSelection($event)">
<mat-list-option [value]="template"
[checkboxPosition]="before"
*ngFor="let template of group.templates">{{template.name}}
</mat-list-option>
</mat-selection-list>
</mat-expansion-panel>
TS
selectedTemplates: Array<TemplateType> =[];
this.serviceCall.subscribe( res => {
this.selectedTemplates = res;
)
当我点击列表中的一个项目时,它们会显示在一个垫子上,并且这样做没有任何问题。
在桌子上,每一行都有一个按钮可以删除我的选择。
单击按钮时如何取消选中列表项
谢谢
【问题讨论】:
-
如果是的话,你认为多选另一种方式吗?请关注stackblitz.com/angular/…
-
嘿 Abhishek,感谢您的回答,但我不喜欢多选,我正在处理多个“选择列表”