I have a case where I'd like to add a context menu to each line of a generated list or table in Angular Material, something like:
<mat-list *ngFor="let item of itemlist">
<mat-list-item>
<some-component [item]="item"></some-component>
<button mat-button [matMenuTriggerFor]="menu">Menu</button>
<mat-menu #menu="matMenu">
<button *ngFor="let option of options" mat-menu-item (click)="fire(item, option)">
{{ option }}
</button>
</mat-menu>
</mat-list-item>
</mat-list
where "some-component" displays whatever the item is, on a single line. The problem is that the menus items don't call the fire method when they're clicked.
My guess is that this is because the menus need their own IDs, but I can't figure out how to do that programatically. I looked at ng-attr-id, but couldn't figure out how to use that with the #menu="matMenu" syntax.
Here's a Stackblitz that has a more detailed example of what I'm after.