How can I stopPropagation when angular mat-select option selected?

Viewed 873

I want to stopPropagation when angular material select changes, Seems like the returned $event doesn't have the stopPropagation()?

<mat-select (selectionChange)="handleSelectionChange($event)">
</mat-select>
2 Answers

Wrap the mat-select with a div. That can be used to capture and stop the same click event that triggers the mat-select selection.

<div (click)="prevent($event)">
  <mat-select (selectionChange)="handleSelectionChange()">
  </mat-select>
<div>

prevent($event) {
  $event.preventDefault();
  $event.stopPropagation();
}

Try using the (valueChange) event. Then use $event.stopPropagation() inside the change handler

<mat-select (valueChange)="handleSelectionChange($event)">
</mat-select>
Related