Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

599
Views
Angular 12 issue with DomSanitizer for src attribute in Iframe. always throw error for dynamicaly set source

I wanted to create a component that handles all YouTube embeded video. However passing the src as a variable will not work at all. No matter what I do. Anyone has an idea what's the problem or is it a bug from angular that needs fixing?

I have this in a parent template

   <ng-container *ngFor="let link of youtubeUrlList">
     <app-youtube-card [url]="link"></app-youtube-card>
   </ng-container>

And the child component template is :

 <iframe [src]="safeSource"></iframe>

and in the child component class :

 export class YoutubeCardComponent implements OnInit {

   @Input() url?: string  
   safeSource?: SafeResourceUrl
   constructor(private sanitizer: DomSanitizer) { }
  
   ngOnInit(){
     this.safeSource = this.sanitizer.bypassSecurityTrustResourceUrl(this.url)
   }
 }

and get this error

core.js:6456 ERROR TypeError: t.replace is not a function
    at HTMLIFrameElement.set (<anonymous>:5:5482)
    at EmulatedEncapsulationDomRenderer2.setProperty (platform-browser.js:739)
    at elementPropertyInternal (core.js:10006)
    at Module.ɵɵproperty (core.js:14764)
    at YoutubeCardComponent_ng_container_1_Template (youtube-card.component.html:3)
    at executeTemplate (core.js:9579)
    at refreshView (core.js:9445)
    at refreshEmbeddedViews (core.js:10570)
    at refreshView (core.js:9469)
    at refreshComponent (core.js:10616)

However i don't get that error if I put any of the youTube link directly in the iframe source attribute

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

I encountered the same error and it was caused by a Chrome extension that was interacting in some way with the iframe behind the scenes.

In Chrome incognito or guest mode my code was working fine, I was facing the problem only when the extension was active.

You should try disabling all of your Chrome extensions.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!