【发布时间】:2018-11-02 11:42:15
【问题描述】:
我正在编写一个带有两个复选框的菜单(来自 Angular 的 mat-menu 带有本机 Javascript 复选框),如果我没有在不起作用的框中准确单击,则菜单正在关闭且未选中该框...
顺便说一下mat-menu我还没有找到当我点击它时如何阻止菜单自动关闭。
你有解决办法吗?
<!-- app.component.html -->
<div class="header">
<mat-toolbar color="warn">OpenLayers</mat-toolbar>
<div class="menu">
<button mat-button [matMenuTriggerFor]="menu">Marqueurs</button>
<mat-menu #menu="matMenu">
<button mat-menu-item>
<p>Piscines : <input type="checkbox" id="piscine" name="piscine" (change)="handleSelected1($event)"/></p>
</button>
<button mat-menu-item>
<p>Parkings : <input type="checkbox" id="parking" name="parking" (change)="handleSelected2($event)"/></p>
</button>
</mat-menu>
</div>
</div>
【问题讨论】:
-
在问题中显示相关标记。
-
所以你没有使用标签?
-
我无法附上我的菜单的截图,但我的菜单上有两个复选框,旁边有它们的标签,我希望我们也可以通过单击标签来选中该框,不一定完全在盒子上
-
请见谅!现在可以用了,非常感谢!!
-
没问题,我很高兴它成功了。 :)
标签: javascript html css angular checkbox