1

Template:

<iframe  width="100%" height="100%"  [src]="url"></iframe>

Component :

I have already transform the url to a safeUrl:

ngOnInit() {
  this.url = this.sanitizer.bypassSecurityTrustResourceUrl('https://www.google.com/');
}

But the page still doesn't show anything,refer to inspect: empty content of the src link

Does anybody know why?

Vivek Doshi
  • 56,649
  • 12
  • 110
  • 122
Dante Jiang
  • 177
  • 1
  • 13

1 Answers1

1

Your code is 100% fine

The issue is with https://www.google.com/, this url

For more detail, please read :

google homepage will not load in an iframe

How to show google.com in an iframe?


Here is the working example of it :

https://stackblitz.com/edit/angular-iframe

Vivek Doshi
  • 56,649
  • 12
  • 110
  • 122