import { Component, OnInit } from '@angular/core'; import { SecurityService } from './data.service'; import { DomSanitizer, SafeHtml } from '@angular/platform-browser'; @Component({ selector: 'app-root', template: `<div [innerHtml] = "safeValue"></div>`, providers: [SecurityService] }) export class AppComponent implements OnInit { safeValue: SafeHtml; constructor(private secure: SecurityService) { this.safeValue = this.secure.getSafeHtml("<h1>Sanitization Success</h1>"); } ngOnInit() { } }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter