Redirect to homepage when click tow time on the tabs


hi community
i want to click two time on the tab then redirect to homepage
any suggestion



maybe this is what you looking for Ionic - Double Tap?

Otherwise you can maybe implement it with a counter and reset it to our needs, for example a timer.

Best regards, anna-liebt


thanks for replay
i try this solution but i get this errore

core.js:1449 ERROR Error: Uncaught (in promise): TypeError: Cannot read property ‘addEventListener’ of undefined
TypeError: Cannot read property ‘addEventListener’ of undefined


this error mean usually that whatever from whatever.addEventListner is not or not at runtime available. Take a look to whatever and clarify why is nothing assigned to whatever.

Best regards, anna-liebt


hi this is my code


import { Component,ViewChild,ElementRef,OnDestroy ,AfterViewInit } from '@angular/core';
import { IonicPage, NavController, NavParams,Tab,Events,Tabs  } from 'ionic-angular';
import {Gesture} from 'ionic-angular/gestures/gesture';
/*import { ReserverPage } from '../reserver/reserver';
import { LacartePage } from '../lacarte/lacarte';
import { AProposPage } from '../a-propos/a-propos';
import { LocaliserPage } from '../localiser/localiser';
import { TelPage } from '../tel/tel';*/

  selector: 'page-tabsreserve',
  templateUrl: 'tabsreserve.html',
export class TabsreservePage {
  @ViewChild('mainTabs') mainTabs: Tabs;
  @ViewChild('element') el: ElementRef;
  reserverRoot = 'ReserverPage'
  lacarteRoot = 'LacartePage'
  aProposRoot = 'AProposPage'
  localiserRoot = 'LocaliserPage'
  telRoot = 'TelPage'
  tab2Params:any ; 
  page:number = 0;
  selectedIndex: string;
  private pressGesture: Gesture;
   // tab2Params = { id: 1, url:"http",cord:"cord" };
  constructor(public navCtrl: NavController,public navParams: NavParams, public events: Events) { = this.navCtrl.parent;
 public ngAfterViewInit(): void {

  this.pressGesture = new Gesture(this.el.nativeElement);

  this.pressGesture.on('doubletap', (e:Event) => {

    // or ... this.yourMethod(e);



public ngOnDestroy(): void {

   ngOnInit() {
    // Let's navigate from TabsPage to Page1


<ion-tabs  #mainTabs (tap)="tapped()"  >
<ion-tab #element [root]="reserverRoot" tabTitle="Reserver" tabIcon="ios-calendar" [rootParams]="tab2Params"  ></ion-tab>
<ion-tab [root]="lacarteRoot" tabTitle="Lacarte" tabIcon="ios-restaurant" [rootParams]="tab2Params"  ></ion-tab>
<ion-tab [root]="aProposRoot" tabTitle="A propos" tabIcon="ios-information-circle" [rootParams]="tab2Params"  ></ion-tab>
<ion-tab [root]="localiserRoot" tabTitle="Localiser" tabIcon="ios-pin" [rootParams]="tab2Params" ></ion-tab>
<ion-tab [root]="telRoot" tabTitle="Tel" tabIcon="ios-phone-portrait-outline" [rootParams]="tab2Params" ></ion-tab>


what is wrong ???..



maybe your @ViewChild(‘element’) el: ElementRef; is the problem. The original post fetch a div as ElementRef which is okay. ion-tab is not a ElementRef to a native element.

Best regards, anna-liebt


thanks for reply
so how can add double click in the tab ?



I didn’t test it, because I am not using ion-tab, but documentation says it is a navcontroller. If NavController doesn’t work and google/bing deliever no results, then you can maybe use your fetched mainTabs and compare it with getselected(), that is that tab you wanna use.

Best regards, anna-liebt