I created a component that should display videos based on properties that are passed to it in input... it works for me if I insert static data, but with the switch no!
export class VideoComponent implements OnInit {
@Input() currentVideo: string | undefined;
url: any;
video: any = { id: 'yOYmdyaSOCg' };
baseUrl: string = 'https://www.youtube.com/embed/';
constructor(
private sanitizer: DomSanitizer,
) {
switch (this.currentVideo) {
case 'foo':
this.video.id = 'yOYSOCsdsdg';
break;
case 'bar':
this.video.id = '3Z4J_bddKE';
break;
case 'foo2':
this.video.id = 'a8DPNc64';
break;
case "bar2":
this.video.id = 'HZySqMdsclEuSQ';
break;
default:
this.video.id = 'TYYW_WsdwYHuM';
}
this.url = this.sanitizer.bypassSecurityTrustResourceUrl(
this.baseUrl + this.video.id
);
}
}
I followed this guide to create it and it works for me, but the switch
doesn't work for me.