1

I'm trying to use DomSanitizer to make my URL safe. I've followed these steps as you can see below:

import { Pipe, PipeTransform } from '@angular/core';
import { DomSanitizer } from '@angular/platform-browser';

@Pipe({
   name: 'youtube',
})
export class YoutubePipe implements PipeTransform {

    constructor(private sanitizer: DomSanitizer){}

    transform(value: string, ...args) {
       value = value.replace('watch?v=', 'embed/');
       console.log(value);
       return this.sanitizer.bypassSecurityTrustResourceUrl(value);
    }
}

That logged value is ok, but I'm getting the error:

ERROR TypeError: Cannot read property 'bypassSecurityTrustResourceUrl' of undefined

which means to me that my object is not getting all set. I've already checked that 'constructor' is being called, so what am I missing here?

Rob
  • 2,243
  • 4
  • 29
  • 40

0 Answers0