当子菜单项路由激活时,我想打开paren mat-menu。
组件html
<li>
<a #open_business="matMenuTrigger" [matMenuTriggerFor]="menu_business" routerLinkActive="active-list-item"
routerLink="/admin/business" [ngClass]="'hasClild'">
</a>
<mat-menu class="dropdown-toggle waves-light" #menu_business="matMenu" yPosition="below">
<ul>
<li class="dropdown-item"><a routerLinkActive="active-list-item"
routerLink="/admin/business/business1">business1</a></li>
<li class="dropdown-item"><a routerLinkActive="active-list-item"
routerLink="/admin/business/business2">business2</a></li>
</ul>
</mat-menu>
</li>
在组件ts
中 @ViewChild('open_user',{static: false}) open_user : MatMenuTrigger
@ViewChild('open_business',{static: false}) open_business : MatMenuTrigger
.
.
.
ngAfterViewChecked(){
if(this.router.url.match(/business/g)){
this.open_business.openMenu()
}
....
}
,上面的代码返回以下错误。 同样也不允许其他动作。
_MatMenu.html:1 ERROR Error: ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value: '@transformMenu: void'. Current value: '@transformMenu: enter'.