Listening to Events on a Host Element in Ionic 2

2 min read

Originally published March 03, 2017

Check out my advanced Ionic tutorials at eliteionic.com

When creating a custom directive (and in other circumstances) you may be interested in listening for events that are happening on the host element. Let's say for example that I created a custom directive that I wanted to attach to the <ion-content> component, like this:

<ion-content myDirective></ion-content>

The host element, which is <ion-content> in this example, may emit events that we want to make use of in our directive. In this video tutorial, we will walk through how you can listen for events on a host element in Ionic 2 (which is just vanilla Angular, it's not specific to Ionic).

Here's the video: