我在点击mat-nav-list项目时尝试触发打开菜单.
原文链接:https://www.f2er.com/angularjs/141481.html<mat-nav-list> <mat-list-item (click)="onOpenMenu(menu)" *ngFor="let i of data"> <div mat-line> {{ i.name }} </div> <p mat-line> {{ i.email }} </p> <button mat-icon-button [matMenuTriggerFor]="menu"> <mat-icon>more_vert</mat-icon> </button> </mat-list-item> <mat-menu #menu="matMenu"> <button mat-menu-item>View profile</button> <button mat-menu-item>Add contact</button> </mat-menu> </mat-nav-list>
TS
onOpenMenu(menu: any): void { // menu doesn't have any openMenu() function // which is of course not a trigger object but a menu itself. console.log(menu); }
我一直试图看看这个更接近我情况的issue on github.但在我的情况下,我有一个动态的项目列表,我想每次点击打开一个菜单.