I am currently working with a component in Angular 6.0.8 that consists of only an iframe element.
Here is the code in page.component.html:
<iframe [src]="url">
The logic for setting the URL is handled in page.component.ts:
ngOnInit() {
this.url = this.route.snapshot.data['url'];
}
However, I have noticed that when I resize the window or click outside of the component causing it to lose focus, Angular will re-render the component triggering lifecycle hooks such as DoCheck, AfterContentChecked, and AfterViewChecked.
As a result, the browser will request the URL in the iframe again, which is not the behavior I anticipated.
How can I prevent this from happening?