In my component template I have code that looks like this:
<div [innerHtml]='sanitizedHtml'></div>
In the component declaration:
let unsafeHtml = '<a routerLink="/some-other-page"> Link </a>';
this.sanitizedHtml = sanitizer.bypassSecurityTrustHtml(unsafeHtml);
Inspecting HTML content in the rendered page I can see the DOM generated, but when I click on the link, nothing happens. I expect, that angular ignored the routerLink directive and did nothing with it.
Any way to work around this?
I could change routerLink to simple href, but in the latter case browser performs the whole page reload, whereas I want to navigate within my angular application.
useHash: true, and have your<a href="#your-route">but it all looks like you're hacking your way inside an angular application. what are you trying to achieve ? why is there a need to use dynamic HTML and not have angular do the heavy lifting ?