Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Angular 15 Mat menu not rendering

I have an actions column in a mat table. In the actions column I have an icon button. I want to show the mat-menu when the icon button is clicked. Below is the column config

  <ng-container matColumnDef="actions">
    <th mat-header-cell *matHeaderCellDef mat-sort-header>Actions</th>
    <td mat-cell *matCellDef="let element">
      <button [matMenuTriggerFor]="appMenu" mat-icon-button aria-label="">
        <mat-icon>more_vert</mat-icon>
      </button>

      <mat-menu #appMenu="matMenu">
        <button mat-menu-item>
          <mat-icon>dialpad</mat-icon>
          <span>Menu item</span>
        </button>
      </mat-menu>
    </td>
  </ng-container>

This does not render the menu upon the button click. But when I move the same code outside the mat table it works. The below works outside the table.

  <button [matMenuTriggerFor]="appMenu" mat-icon-button aria-label="">
    <mat-icon>more_vert</mat-icon>
  </button>

  <mat-menu #appMenu="matMenu">
    <button mat-menu-item>
      <mat-icon>dialpad</mat-icon>
      <span>Menu item</span>
    </button>
  </mat-menu>

Am I missing something or this is a bug with Angular material?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

I just tried what you suggest in this demo, and it works fine

enter image description here

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading