Toggling Images

In this lecsson, we're going to start toggling images.

We’re able to highlight different buttons based on the current active image. Let’s make the buttons functional by listening to click events on them. If clicked, we’ll update the activeImg property to the index. We’ll also make the previous and next buttons functional. The goal is to allow the user to navigate between images with the pagination menu.

Listening for click events

We already know how to listen for events on an element. We add a pair of parentheses with the name of the event we want to listen to. We’ll update the app.component.html file to the following:

Get hands-on with 1200+ tech skills courses.