简体   繁体   中英

ng-click not working in font-awesome icon

I have added my demo to: this link When I click on thumbs up (comes from fontawesome) ng-click does not trigger and like count does not change. When I click to xyz, like count increases.

This is not working:

<i ng-click="LikeComment(comment)" class="far fa-thumbs-up"></i> {{comment.like}} 

But this is working:

<i ng-click="LikeComment(comment)">xyz</i> {{comment.like}}

Try this:

<span ng-click="LikeComment(comment)"><i class="far fa-thumbs-up"></i></span>{{comment.like}}

OR , in case you are ok with a button

<button ng-click="LikeComment(comment)"><i class="far fa-thumbs-up"></i></button>{{comment.like}}

Font awesome turns it into a <svg> tag which doesn't seem to collaborate too well with the click handler. Try wrapping the <i> in a <div> like this

https://jsfiddle.net/wewekvkw/26/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM