I've got a dropdown menu in my navbar which I open and close by adding a show
class to it when clicked.
This works but requires the user to click the button again to close the menu. As a semi-solution I now listen for router changes and close the menu whenever the route changes.
However I'd like the menu to close if anything except the menu button is clicked. So that users can click the background to get rid of the menu. How do I achieve this?
<button class="btn btn-link nav-link dropdown-toggle" (click)="showDropdown=!showDropdown" id="navbarDropdown" role="button" >
<div class="dropdown-menu" [ngClass]="{'show': showDropdown}">
Please don't offer solutions with jquery. I am not using it in this project.