3

Hi i am trying to load html file into iframe, but it is not working, If i load any external url it is working

in Component.ts

name = 'Set iframe source';
  url: string = "./add-cardIframe.component.html";
  urlSafe: SafeResourceUrl;

in oninit
ngOnInit() {
    this.urlSafe= this.sanitizer.bypassSecurityTrustResourceUrl(this.url);
  }

HTML File:

<iframe width="100%" height="100%" frameBorder="0" [src]="urlSafe"></iframe>

getting error as Cannot match any routes. URL Segment: 'add-cardIframe.component.html' any help on this issue would be great

1 Answer 1

1

Html:

<div [innerHTML]="html"></div>

TypeScript:

this.html = this.sanitizer.bypassSecurityTrustHtml(
      '<iframe width="100%" height="800" src="https://primefaces.org/primeng/#/"></iframe>',
    );
Sign up to request clarification or add additional context in comments.

1 Comment

It bleeds inline styles to the whole application, they don't stay inside the iframe

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.