Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IONIC 2 IOS issue - tap or click on ion button trigger event twice

I have developed one IONIC 2/Angular 2 app, it is running good in android but when I use it in IOS it triggers the click event twice but once in android.

here is my header:

<ion-header>
    <ion-navbar>
        <button menuToggle>
            <ion-icon name="menu"></ion-icon>
        </button>
        <!--<ion-title *ngIf="post">{{post.title.rendered}}</ion-title>-->
        <ion-buttons>
          <button (click)="ScrollToBottom()" class="details_btn blicon-comments" ion-button icon-only>
          </button>
        </ion-buttons>
        <ion-buttons>
          <button (click)="toggleFonrResizer()" class="details_btn  blicon-text-file-font" ion-button icon-only>
          </button>
        </ion-buttons>
        <ion-buttons>
            <button (click)="favoritePost(post)" ion-button icon-only class="details_btn blicon-bookmark"></button>
         </ion-buttons>
        <ion-buttons>
          <button (click)="sharePost()" class="details_btn blicon-share" ion-button icon-only>
          </button>
        </ion-buttons>
    </ion-navbar>
    <ion-toolbar [hidden]="hideFontResizer" class="fontresizer">
        <button left (click)="fontSizeChange(-0.1)"><ion-icon name="remove"></ion-icon></button>
        <button right (click)="fontSizeChange(0.1)"><ion-icon name="add"></ion-icon></button>
    </ion-toolbar>
</ion-header>

Clicking on any button in IOS app fires the event twice even the share popup shows twice and bookmark gets auto removed because second tap in bookmark is to remove from bookmark.

Please tell me what is causing this.

Thanks Sanny

like image 267
Sanny Srivastava Avatar asked Oct 14 '25 15:10

Sanny Srivastava


1 Answers

One upvote reminded me that someone also is having the same issue what I had.

Here is how I fixed this :-

Open your app.module.ts file and under imports: [..] replace the following line

IonicModule.forRoot(MyApp),

with

IonicModule,

I can not explain why this worked me but this saved my day.

If someone know please explain the reason why this hack worked.

Thanks Sanny

like image 146
Sanny Srivastava Avatar answered Oct 17 '25 05:10

Sanny Srivastava



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!