Tutorial hero
Lesson icon

Listening to Events on a Host Element in Ionic 2

Originally published March 03, 2017 Time 1 mins

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:

Learn to build modern Angular apps with my course