1

I am trying to include an iFrame in my Angular 2 app but I keep getting the following error,

unsafe value used in a resource URL context

I am trying to generate a dynamic URL to send as a param into the iFrame.

<iframe [src]="url" width="560" height="600" frameborder="0"></iframe>

    ngOnInit(): void {

    this.myData = this.store.select<myState>('myData').subscribe(state => {
      this.myData = state.myData;
      this.loading = state.loading;

      if (this.myData) {
        this.url = `www.google.com`;
      }

      console.log(this.url);
    });
  }

I have tried to implement both these solutions but still getting the same error

How to set iframe src in Angular 2 without causing `unsafe value` exception?

and

https://plnkr.co/edit/Uifk3dxf7vwKJsUFb0d9?p=preview . which I got from an other stack overflow answer.

Community
  • 1
  • 1
Vijay
  • 600
  • 6
  • 16

1 Answers1

1

Apparently I did a wrong implementation so one answer from an other thread was failing, but someone pointed out my mistake and now the implementation works. Here is the link that worked for me

How to set iframe src in Angular 2 without causing `unsafe value` exception?

Community
  • 1
  • 1
Vijay
  • 600
  • 6
  • 16