I need to add a click event to image in angular component. I tried:
<img src="../../assets/add.svg" width="18" height="18" (click)="addItem()">
but this does not work. If put image inside button like this:
<button type="button" class="btn_img" (click)="addItem()">
<img src="../../assets/add.svg" width="18" height="18">
</button>
It looks like a button with an image inside, I do not want this, I want it to look like:
<img src="../../assets/add.svg" width="18" height="18">
but that works like:
<button type="button" class="btn_img" (click)="addItem()">
<img src="../../assets/add.svg" width="18" height="18">
</button>
How I can get this, how do you do this in angular?
div
rather than abutton
to see if that works? And, adding the(click)="addItem()"
to thediv
. Something like that. Bit of a guess.<input type="image">
, but I don't know how/if that would affect Angular.(click)
functionality works on images. There is likely something else causing the issue that isn't covered in your question or an error in your DOM that you haven't caught when adding that button. Working proof of (click) working on img: stackblitz.com/edit/github-hibfhb