Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Clickable icon inside div

How to avoid triggering the div click event when clicking on ion-icon

<div(click)="goNext()">
    <ion-icon  name="close-circle-outline" size="large" (click)="dissmiss()"></ion-icon>
</div>

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

On the dissmiss function you have to write your icon code logic. after performing you have to place event.stopPropagation() at the end of dissmiss function to stop event to trigger the parent events.

like this:

function dissmiss(event){
  // write code for icon close.
  event.stopPropagation();
}

the above code runs the logic that you written for icon close and the stopped immediately at this function and will not go to the parent node click.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading