Skip to content

Why does EventEmitter not working on mat-menu? #17591

@zinzinday

Description

@zinzinday

What is the expected behavior?

The purpose is that I want to reconfirm whether the customer really wants to delete the content.
I have created custom directive AlertConfirmDirective.
When you click the button (delete), open a dialog to verify that it is no / yes. If Yes, it will emit to event (onConfirmed)
It's working fine normal component
but when using it on mat-menu with lazy list item. it do not working.
I have tired to try with change-detection strategy, setTimeout,... but all not working for me.

Reproduction

What are the steps to reproduce?
I have deployed my mini repo to : Stackblitz

<mat-menu #itemActions="matMenu">
  <ng-template matMenuContent let-item="item">
    <button mat-menu-item>{{item.name}}</button>
    <button mat-menu-item 
    alert-confirm 
    name="banking" 
    (onConfirmed)="onDelete(item)">
      Delete
    </button>
  </ng-template>
</mat-menu>

Directive called and dialog open but EventEmiter (onConfirmed) not working.
Please review my repo and help me.

Thanks advaced

Environment

Angular CLI: 8.3.14
Node: 10.17.0
OS: linux x64
Angular: 8.2.12
@angular/material/ cdk 8.2.3

  • Browser(s): Chrome latest stable
  • Operating System: Ubuntu 16.04

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions