Cross component event handling in Ionic2


#1

Does anyone know what the recommended way of creating cross-component events is in an Ionic2 app?

Let’s say I have a button on a page and when that button is clicked I want an event to run in another page/controller. What’s the method now for subscribing to an event that is fired in another component?


#2

Ok, I think I found out how - the Angular2 EventEmitter (I think)


#3

From a purely Angular standpoint, you have two options: event emitters or using a service that both components consume.

I’m still pretty new to Ionic 2 and Angular 2 so there might be a better way baked in.


#4

You can use the Ionic2 Events as well. https://github.com/driftyco/ionic/tree/2.0/demos/events


#5

thank you for showing this https://ionicframework.com/docs/v2/api/util/Events/ :grin:
similiar like $rootScope in ionic 1 :grinning: