material icon indicating copy to clipboard operation
material copied to clipboard

md-menus not closing when using ng-repeat

Open reylibutan opened this issue 11 years ago • 4 comments

<md-menu-bar>
      <md-menu ng-repeat="section in sections">
        <md-button class="navButton" ng-click="$mdOpenMenu()">
          {{section.name}}
        </md-button>
        <md-menu-content>
          <md-menu-item>
            <md-button>Subsection 1</md-button>
          </md-menu-item>
        </md-menu-content>
      </md-menu>
</md-menu-bar>

I am doing something like above but unfortunately, if I click a menu, it stays open even if I click other buttons.

I just want it to have the same behavior as

https://material.angularjs.org/latest/demo/menuBar

P.S. If I don't use ng-repeat (meaning, menus are static), it works fine though.

reylibutan avatar Oct 14 '15 09:10 reylibutan

Any ideas how I could fix this? I will try to setup a plunker for this one.

reylibutan avatar Oct 19 '15 09:10 reylibutan

You can inject $mdMenu on your controller and use $mdMenu.hide(); by the end of the function called by the item of the menu.

mario-aleo avatar Oct 19 '15 10:10 mario-aleo

+1

johnSowingo avatar Oct 26 '15 17:10 johnSowingo

Duplicate of #4484 ... but would be nice to have an interim solution as this is rather frustrating.

andrew-cunliffe avatar Oct 30 '15 18:10 andrew-cunliffe