gpt4 book ai didi

angular - 如何从 typescript 访问垫菜单触发器

转载 作者:太空狗 更新时间:2023-10-29 18:03:38 25 4
gpt4 key购买 nike

我有以下 html:

<button mat-icon-button #notificationMenuBtn [matMenuTriggerFor]="notificationsMenu">
</button>
<mat-menu #notificationsMenu="matMenu" [overlapTrigger]="false">
</mat-menu>

如何从 typescript 访问 notificaitonMenuBtn 上的 thematMenuTriggerFor?我尝试使用 View Child(如下所示),但我似乎无法将其绑定(bind)到触发器,只能绑定(bind)到按钮。

@ViewChild('notificationMenuBtn') notificationMenuBtn : MatMenuTrigger;
this.notificationMenuBtn.openMenu();

最佳答案

如果你真的需要使用一个id(当你有多个MatMenuTrigger时)

@ViewChild('notificationMenuBtn', {read: MatMenuTrigger}) protected notificationMenuBtn : MatMenuTrigger;

关于angular - 如何从 typescript 访问垫菜单触发器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47080338/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com