访问模板内容的“角度”方式是通过
@ViewChild
@ViewChidren
HTML格式
<button [matMenuTriggerFor]="menu1">Test</button>
<mat-menu yPosition="below" #menu1="matMenu">
<button mat-menu-item><mat-icon>account_box</mat-icon> My Profile</button>
<button #roleMenuButton class="role-menu" mat-menu-item><mat-icon>lock</mat-icon> API Keys</button>
<button mat-menu-item><mat-icon>power_settings_new</mat-icon> Logout</button>
</mat-menu>
import { AfterViewInit, Component, ElementRef, QueryList, ViewChildren } from '@angular/core';
...
@ViewChildren('roleMenuButton') roleMenuButtons: QueryList<ElementRef>;
...
ngAfterViewInit(){
let elements = this.roleMenuButtons.toArray();
console.log(elements);
}