角材料垫列表选项

时间:2018-08-28 14:59:57

标签: angular typescript angular-material2

在Material 2中是否可以通过事件函数检测复选框为true还是false。传递$ event仅检测打字稿侧的鼠标或键盘,需要检测它是否被选中。

<mat-selection-list #list   >
  <mat-list-option *ngFor="let aser of fo; let i = index" (click)="onAreaListControlChanged(aser.ID, aser.Name, aser.Number, $event)"  checkboxPosition="before"    [value]="aser.Number" [selected]="aser.selected"  >
    <span style="font-size:11px"  >{{aser.selected}} {{aser.first}} - {{aser.Number}}</span>
  </mat-list-option>
</mat-selection-list>

打字稿

onAreaListControlChanged(sid, sname, snum, $event) { if(checked==true else false}

1 个答案:

答案 0 :(得分:0)

使用MatSelectionList的<div *ngFor="let element of array"> <input type="text" class="css-class-name"> </div> 事件。事件对象是selectionChange,它提供了单击的MatSelectionListChange作为MatOption属性,这又为您提供了option(选中)值:

selected

TS

<mat-selection-list #list (selectionChange)="selectionChange($event.option)"  >
    <mat-list-option *ngFor="let aser of fo; let i = index" (click)="onAreaListControlChanged(aser.ID, aser.Name, aser.Number, $event)"  checkboxPosition="before"    [value]="aser.Number" [selected]="aser.selected"  >
        <span style="font-size:11px"  >{{aser.selected}} {{aser.first}} - {{aser.Number}}</span>
    </mat-list-option>
</mat-selection-list>