Для этого вам нужен канал и используйте DomSanitizer
например
import { MyApp, SafePipe } from './myapp.component';
@NgModule({
declarations: [
AppComponent,
SafePipe
],
Создать трубу в вашем приложении
import { Component, ViewEncapsulation, ViewChild, ElementRef, PipeTransform, Pipe, OnInit } from '@angular/core';
import { DomSanitizer } from "@angular/platform-browser";
@Pipe({ name: 'safe' })
export class SafePipe implements PipeTransform {
constructor(private sanitizer: DomSanitizer) { }
transform(url) {
return this.sanitizer.bypassSecurityTrustResourceUrl(url);
}
}
@Component({
selector: 'app-root',
templateUrl: './myapp.component.html',
styleUrls: ['./myapp.component.css']
})
export class MyApp {
title = 'app';
myiframe: string = "your_url_here"
}
В вашем HTML
<iframe width="420" height="345" [src]="myiframe | safe">
</iframe>