selectionChange 属性 未在 angular class 组件中触发事件

selectionChange property is not firing event in angular class component

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

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

我在发布到 angular 6 时做错了什么或有什么问题吗?

使用:Angular 6.0.1 版本

Chrome 浏览器

@angular/material 的 6.0.0-beta.5 中的组件行为已更改:

list: selectionChange on the MatListOption, which was deprecated in 5.0.0 has been removed. Use selectionChange on the MatSelectionList instead.

您需要像这样在 mat-selection-list 上应用 selectionChange :

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

Here is an edit of your stackblitz.