selectionChange属性不是在角类组件中触发事件

Ani*_*rya 2 angular-material2 angular angular6

我试图实现angular MatSelectionList并尝试使用API selectionChange监听选定的选项事件,但它没有触发任何事件.

https://stackblitz.com/edit/angular-eyjdfp?file=app%2Flist-selection-example.html

我做错了什么或者在释放角度6时有什么破坏?

使用:Angular 6.0.1版本

Chrome浏览器

ibe*_*oun 11

组件行为在@ angular/material 的6.0.0-beta.5中发生了变化:

list:已删除在5.0.0中弃用的MatListOption上的selectionChange.而是在MatSelectionList上使用selectionChange.

您需要申请selectionChange对你mat-selection-list是这样的:

<mat-selection-list (selectionChange)="onSelection($event)" #shoes>
  <mat-list-option *ngFor="let shoe of typesOfShoes" >
    {{shoe}}
  </mat-list-option>
</mat-selection-list>
Run Code Online (Sandbox Code Playgroud)

这是你的stackblitz的编辑.