Ionic (click) event firing 3 times only on IOS devices


#1

I was having an issue where images were uploading to my AWS server multiple times. After some logging I found that for some reason my array of images was triple the size it should have been. For some reason any of my (click) events throughout the various pages of my application are triggering 3 times on my IPhone and IPad. I tested this in the browser (Chrome & Safari) and the (click) event only triggers 1 time. I tried it on my Android device and again, it only triggers the event 1 time. I’d be happy to share some code if anyone has a suggestion of what to share… for starters, here is the button and the function it calls (nothing ground-breaking):

**service-checklist.html**    
<button ion-button full (click)="testEvent()">Test</button>

**service-checklist.ts**
export class ServiceChecklistPage {
    constructor(){

    }
    testEvent(){
        console.log('CLICKED!');
    }
}

I’d really appreciate any help I can get here. I’ve scoured the forums and keep seeing posts in regards to ng-click, but I have confirmed this is only occurring on my IOS devices which is unfortunate.

Thanks!


#2

Figured it out. I had put together a few modules that I was including in my app.module.ts file. In the 2 modules I created I accidentally had the MyApp component again, which was causing any event to occur 3 times. I’m not quite sure why it was only impacting iOS though… maybe Android has a built in prevention for things like that.


#3

Thank you for this. I was also making a simple but major mistake. In all my modules is was using the full IonicModule.forRoot(MyApp) where the correct was was to just include IonicModule and then only call the full IonicModule.forRoot(MyApp) in the root app.module.ts. The forRoot() method is only for the root module. Go figure.


#4

i have been try your solution but its doesn’t work for me…it’s give me this error

Error: Could not find IonicModule.forRoot call in "imports"
    at BuildError.Error (native)
    at new BuildError (/Users/devman/code/mobile-app/new app/b/purchasekaro-ionic2/node_modules/@ionic/app-scripts/dist/util/errors.js:16:28)
    at /Users/devman/code/mobile-app/new app/b/purchasekaro-ionic2/node_modules/@ionic/app-scripts/dist/preprocess.js:18:21