Reputation: 16949
I have a div with innerhtml containing multiple link tags. When clicking on any of the a link tags I want to trigger a function in angular2. Can angular2 take over the click event of the href tags and get the clicked word or innerhtml tag which was clicked?
Upvotes: 0
Views: 856
Reputation: 657376
You can add a host listener to your component and then figure out the rest from the passed event:
@HostListener('click', ['$event'])
onClick(event) {
if(event.target ...) {
}
}
Upvotes: 3