title: Angular 7 : close menu when click outside
body: <p>I would like to know whenever click is triggered inside parent div #menu, irrelavant of html tags exists inside it.</p>
  
  <p>nativeElement.parent didn't worked for me. </p>
  
  <p>HTML code:</p>
  
  <pre><code>&lt;button #toggleButton (click)="toggleMenu()"&gt; Toggle Menu&lt;/button&gt;
  
   &lt;div class="menu" *ngIf="isMenuOpen" #menu&gt;
      &lt;div&gt;
        I'm the menu. Click outside to close me
      &lt;/div&gt;
      &lt;/div&gt;
  </code></pre>
  
  <p>Angular script:</p>
  
  <pre><code>this.renderer.listen('window', 'click',(e:Event)=&gt;{
  
          if(e.target !== this.toggleButton.nativeElement &amp;&amp; e.target!==this.menu.nativeElement){
              this.isMenuOpen=false;
          }
      });
  </code></pre>
  
  <p>This is not working.</p>