The data source I get passed something like:
<a href="javascript:blahblah...>Something</a>
And I assigned it to say anchor: HTMLAnchorElement; in the component. When I try to display it in template like this:
{{anchor}}
It comes out as javascript:0 blehblahek.
What I want to do is just pass that HTML Element to the template. How can I do this?
You are looking for innerHTML, for example:
Component
someHtmlCode: string = "<div><b>This is my HTML.</b></div>"
Template
<div [innerHTML]="someHtmlCode"></div>
But, if you want to pass script tag or some other potentially dangerous code, you need to use DomSanitizer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With