<div [innerHTML]=.... not working with iframe html> in angular2 html inject

DomSanitizationService is outdated from angular2 RC6

If you are using angular2 RC5 use this-

DomSanitizationService

If you are moving to angular2 RC6 use this-

DomSanitize

Here, is the complete example

import {DomSanitizer} from '@angular/platform-browser';

Then add in constructure

private sanitizer: DomSanitizer

and apply sanitizer on your variable like this

let text = <iframe width="977" height="733" src="https://www.youtube.com/embed/C0DPdy98e4c" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
text = this.sanitizer.bypassSecurityTrustHtml(text);
return text;

Innerhtml Angular 8

this.sanitizer.bypassSecurityTrustHtml() takes string as input and makes it SafeHtml.I have done this in Angular 8.


Working PLUNKER

You need to use bypassSecurityTrustHtml for that, and need to assign and use the sanitized html like this

this.html = this.sanitizer.bypassSecurityTrustHtml(this.html);