David Prieto
David Prieto

Reputation: 2299

How to display dropdown menu from an icon button in Ionic?

I'm trying to create a dropdown menu with the options "share" and "delete" that displays from an icon button, but Ionic doesn't support it out of the box.

The button in question is like this:

<button class="button button-icon icon ion-navicon-round" ng-click="show()"> 
</button>

I checked the question (ionic how to display a dropdown of choices on button click) but it didn't help.

Maybe I need some Angular.js trick? I'm new in both Angular.js and Ionic framework.

Upvotes: 1

Views: 19036

Answers (1)

aorfevre
aorfevre

Reputation: 5064

What you are looking for is component $ionicPopover

First create your component

$ionicPopover.fromTemplateUrl('settings.html', {
    scope: $rootScope,
}).then(function(popover) {
    $scope.popup = popover;
});

Then you can show it from ng-click of your button

 $scope.show= function($event) {
    $scope.popup.show($event);
 };

Ng-click of your function shall be updated also to send the $event paramenter

 ng-click="show($event)"

Upvotes: 9

Related Questions