我创建了一个函数,当用户单击该项目时,在单击该项目的屏幕上显示Toast(警报):
我的.ts文件中的功能:
itemSelected(item: string) {
this.toastCtrl.showToast("Selected Item: " + item, 'bottom');
}
按键:
<button ion-item *ngFor="let item of people" (click)="itemSelected(item)">
{{ item.firstname }}
</button>
这正常工作,但是,当用户长按该项目时,现在我想创建一个选项列表。在本机Android中,可以使用
setOnItemLongClickListener
方法执行此操作,但是我不知道Ionic中的等效功能是什么?哪种方法等效于Ionic 2中的setOnItemLongClickListener
? 最佳答案
您可以尝试Ionic 2手势提供的press
事件。查看有关手势here.的文档
<button ion-item *ngFor="let item of people" (press)="itemSelected(item)">
{{ item.firstname }}
</button>
关于android - 等同于Ionic 2中的setOnItemLongClickListener,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/42231885/