Skip to content
Advertisement

Catch the click event on class inside SVG in Angular

In my Angular 9 app I need to add the svg file as an interactive image.

The svg itself is in my-file.svg and looks like this:

JavaScript

I have a component:

JavaScript

And in the car-view.component.html I include this svg as:

JavaScript

How can I call the elementClicked() function inside CarViewComponent on click event on my-polygon-class (which is inside the svg)? I also need to toggle another class (say element-clicked) in order to mark the svg polygon as clicked.

Advertisement

Answer

add it in this way

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