I'm facing an issue with adding a click event to an image within an Angular component. I have tried the following code:
<img src="../../assets/add.svg" width="18" height="18" (click)="addItem()">
However, this approach does not seem to work as expected. If I place the image inside a button like so:
<button type="button" class="btn_img" (click)="addItem()">
<img src="../../assets/add.svg" width="18" height="18">
</button>
This renders the image within a button element, which is not what I desire. I want it to appear as follows:
<img src="../../assets/add.svg" width="18" height="18">
But still be functional, similar to how this code snippet works:
<button type="button" class="btn_img" (click)="addItem()">
<img src="../../assets/add.svg" width="18" height="18">
</button>
What is the best practice for achieving this in an Angular application?