[SOLVED] EventController.on triggered incrementally


#1

Hi,

My app follows a master/detail pattern. The first screen displays a list of items, and the second screen displays the details of the touched item.
To fetch the item information, I call a custom service which triggers an ionic.EventController.trigger('fetchFinished', {});

The detail controller listens to this fetchFinished event (ionic.EventController.on('offerService.sendProposal.finished', ...) and sets $scope values with the retrieved service’s local vars.

When I access for the first time my detail controller, the service triggers 1 event and the controller receives 1 event.
When I go back to the master view, and go to another item details view, the service triggers 1 event but the controller receives 2 events.
And this behaviour goes on infinitely…

I think that I need to “unregister” this event but I’m not 100% sure.

Can somebody help me?

Thanks!


#2

Mistake of mine…

Ionic event are global and each time you tell Ionic to listen to something, it will add a listener to something like a listening stack. This behaviour is normal and logical.

Removing events and adding promises to services fixed everything.