我有以下组件
@Component({
selector: 'app-models-sd-htmlview',
styleUrls: ['./sd.component.scss'],
template: `
<iframe id="htmlview" style="width:100%; height:200%;" [src]="iframe"></iframe>
`
})
export class HtmlViewComponent implements OnInit {
@Input() urlhash;
@Input() predictiontag;
public iframe;
constructor(public sanitizer: DomSanitizer)
{
this.sanitizer = sanitizer;
};
ngOnInit()
{
var url = "http://localhost:8080/htmlview/" + this.urlhash + "/" + this.predictiontag + ".html";
this.iframe = this.sanitizer.bypassSecurityTrustResourceUrl(url);
}
}
<app-models-sd-htmlview [urlhash]="urlhash" [predictiontag]="predictiontag"></app-models-sd-htmlview>