Is it possible to bind to an event which is from external content. Content is brought in via innerHTML
I have the below code whereby I grab external content and display it within my app. I'm trying to listen to an onClick event for the <a> tag. The <a> is a route redirect. The listen should reside within my app as I want do some other things before routing to a new route.
I've tried setting a handleClick function but I don't think this is the correct way to do it.
I also thought maybe using a ElementRef - in this case #view but would jquery light be better in this case.
@Component({
selector: 'overview-details',
template: `
<h2>{{ title }}</h2>
<div #view [innerHTML]="regCode | sanitizeHtml"></div>
`
})
ngOninit() {
this.regcode = `
<div>
<h1>RegCode Content</h1>
<a class="link" (click)="handleClick()">Link</a>
</div>
`;
}
//within controller
handleClick(){
// do some stuff
// then route
router.navigate([somewhere....]);
}