Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

iframe angular src detect changes

/// HTML
// <iframe *ngIf="src" [src]="src" #iframeYoutube
//  frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
//  allowfullscreen></iframe>

@ViewChild('iframeYoutube') iframeYoutube: ElementRef;

ngOnChanges(changes: SimpleChanges): void {
    this.src = changes['source'].currentValue;
    if (this.iframeYoutube) {
      this.iframeYoutube.nativeElement.src = this.src;
    }
  }
 
PREVIOUS NEXT
Tagged: #iframe #angular #src #detect
ADD COMMENT
Topic
Name
4+2 =