Sanny Srivastava
Sanny Srivastava

Reputation: 1157

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

Upvotes: 4

Views: 1732

Answers (1)

Sanny Srivastava
Sanny Srivastava

Reputation: 1157

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

Upvotes: 2

Related Questions