title: mat-menu in ngFor doesn't work in production build (Angular 4)
body: <p>I was attempting to create a list with a menu for each list items using ngFor in Angular 4. The menus work when building in development mode but it doesn't work properly when building in production mode. When I click the button on the list item, the menu toggles on but clicking in other places will not toggle it off. Below is the code I am using.</p>
  
  <pre><code>&lt;mat-list&gt;
      &lt;a mat-list-item *ngFor="let forest of forests"&gt;
          &lt;h4 mat-line&gt;{{ forest.name }}&lt;/h4&gt;
          &lt;mat-menu #m="matMenu"&gt;
            &lt;button mat-menu-item (click)="onEdit(forest)"&gt; Edit &lt;/button&gt;
            &lt;button mat-menu-item (click)="onDelete(forest)"&gt; Delete &lt;/button&gt;
          &lt;/mat-menu&gt;
  
          &lt;button mat-icon-button [matMenuTriggerFor]="m"&gt;&lt;mat-icon&gt;more_vert&lt;/mat-icon&gt;&lt;/button&gt;
          &lt;mat-divider&gt;&lt;/mat-divider&gt;
      &lt;/a&gt;
  &lt;/mat-list&gt;
  </code></pre>