I do have html content comes from the API.
How do I display it with iframe ?
Something like
{ ..., template: "<h3 style="margin: 0px; padding: 0px; ..." ...}
Please provide demo if possible.
Thanks.
I do have html content comes from the API.
How do I display it with iframe ?
Something like
{ ..., template: "<h3 style="margin: 0px; padding: 0px; ..." ...}
Please provide demo if possible.
Thanks.
Create a pipe for iframe
import { Pipe, PipeTransform } 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);
}
}
And in the component
@NgModule({
declarations : [
...
SafePipe
],
})
HTML
<iframe width="100%" height="300" [src]="url | safe"></iframe>
You can refer this Plunker
For Angular1.x Plunker