Sunday 1 July 2018

Create your custom HTML DOM in Angular.

you have to implement the methodDomSanitizer from to@angular/platform-browser make your custom element a trusted HTML tag.
You can learn more about Angular elements here
import { DomSanitizer } from '@angular/platform-browser';
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-dashboard',
template: `<div [innerHtml]="content"></div>`
})
export class DashboardComponent implements OnInit {
content: any;

constructor(private _domSanitizer: DomSanitizer) {
}

ngOnInit() {
this.content = this._domSanitizer.
bypassSecurityTrustHtml('<h1>This is DonSanitizer</h1>')
}
}