This may not be the 'cleanest' approach though it runs in Angular 6.
First I created a component called dummy.ts, [you can call it any name you want...]
using following ng command
ng generate component dummy
Before adding anything in dummy.ts component content, I first needed to define a pipe file. For convenience I generated the pipe in same dummy.ts component folder, using following ng command:
ng generate pipe SafeHtml
I then added the following code:
import { Pipe, PipeTransform } from '@angular/core';
import { DomSanitizer } from '@angular/platform-browser';
@Pipe({
name: 'safeHtml'
})
export class SafeHtmlPipe implements PipeTransform {
constructor(private sanitized: DomSanitizer) {}
transform(value) {
return this.sanitized.bypassSecurityTrustHtml(value);
}}
Finally back in dummy.ts I added this very simple basic code.
import { Component, OnInit } from '@angular/core';
import {BrowserModule} from '@angular/platform-browser';
import { FormsModule } from '@angular/forms';
import { DomSanitizer } from '@angular/platform-browser';
import { SafeHtmlPipe } from './safe-html.pipe';
@Component({
selector: 'app-dummy',
templateUrl: './dummy.component.html',
styleUrls: ['./dummy.component.css']
})
export class DummyComponent implements OnInit {
name:string;
safeHtmlContent : string;
dummyContent : string;
onClick(){
this.safeHtmlContent = this.dummyContent;
}
constructor() {
this.dummyContent = '<h4>Some dummy title</h4><p>Some blah blah blah blah blah... dummy content</p>';
}}
and in dummy.html I simply added the following:
<div>
<button (click)="onClick()">Click</button>
</div>
<div [innerHtml]="safeHtmlContent"></div>
As a result when a click on button it displays expected raw HTML

Hope this helps ;)