How to fix problem close drpdown when i click outside it : I am developping an angular 5 project. My home page is composed by many components. In navbarComponent i have a dropdown list.
I want when the dropdown list is open if i click outside it,it will close automatically.
This is my code:
















        ngOnInit() {
        this.showMenu = false;}
        toggle() {
        this.showMenu = !this.showMenu;
        }
       <div *ngIf="isConnect" class=" userStyle dropdown-toggle " (click)="toggle()">
    
                  
    
                    <ul class="dropdown-menu subMenu" role="menu" *ngIf="showMenu">
            
                        <li (click)="profile()" class="subMenuItem"> PROFILE</li>
                        <li (click)="administration()" class="subMenuItem subMenuItem-last">ADMINISTRATION</li>
                        <li class="subMenuItem subMenuItem-last"><button class="btn blue-btn" (click)="logout()" ><mat-icon mat-list-icon fontIcon="icon-logout"></mat-icon>LOGOUT</button></li>
                    </ul>
                </div>


