Skip to content
Advertisement

Bootstrap carousel slide.bs.carousel or slid.bs.carousel event not firing with Angular

I’ve checked everywhere with no luck. I’m trying to detect when the carousel changes to a new slide (weather automatically or by user click). I have tried many combinations with no luck. The event just does not fire at all. I’ve used the event handler .on to attach events in the typescript file but they do not fire. I’ve also tried the now deprecated .bind as well and again nothing happens. Using Angular 8.3 Bootstrap 4.4.1

Here is the HTML

JavaScript

And the typescript

JavaScript

Advertisement

Answer

There are a few different ways to do this, but the below works well for me:

First run the below command to add bootstrap carousel environment:

JavaScript

then app.module.ts:

JavaScript

add the below in app.component.ts

JavaScript

lastly, app component.html file:

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement