I have a long piece of text to display in my app and so I want to use a string of HTML.
// component
description: string = `<p>Hello world. <a routerLink="/home">Click here</a> to go to the home page.</p>`;
// template
<div class="content">
<div innerHTML="description"></div>
</div>
This renders correctly, except Angular strips out the routerLink
piece and the link doesn't work. I have tried using a custom pipe to pass the string through the DomSanitizer
function bypassSecurityTrustHtml()
, but Angular doesn't pick up on the syntax and does not treat it as a routerLink
.