Dropdown menu on long press


#1

Hello,

I’m trying to get a dropdown menu with a list of options whenever i long press on a component. Then use one of those options to do some actions calling an API.
I can do the second part easily, yet i’m looking for a hint/help on the first one, the dropdown menu. I dont want to show the arrow neither the name of the selected option as its here .

Is there something like (press)=“callsomefunction()” ?

Thanks in advance!


#2

Greetings, could you tell us what version of ionic you are working on, part of the code you are doing to help you in this way better?


#3

sorry about that! I’m using ionic 3.

<ion-list>
<ion-item (click)="doSomething(user_id)" (press)="menu(option_id)">
<ion-grid>

_my code here_

</ion-grid>
</ion-item>
</ion-list>

#4

Adding hammerjs to the project could solve the event request. As to hiding the arrow, you are going to have to crack open the CSS and figure out what to override.


#5

well, ionic have a (press) event and thats enough to me. i’m just trying to get a dropdown menu when i press on that area. like when you press on a msg on whatsapp it shows options (copy/forword/…etc).


#6

So If you don’t mind to mix up ionic with angular material you can take a look at

https://material.angular.io/components/menu/overview

But I’m not sure if it is a good idea to mix these two things together…
:confused:


#7

Solved with PopoverController !
i just added (press) to the container and called PopoverController function.

Thanks all for your effor n_n