I’m trying to have “users” enter an embeded youtube link via alertcontroller promp box but I keep getting this error once they click save/add the video:
Runtime Error
Error in ./HomePage class HomePage - caused by: unsafe value used in a resource URL context
Stack
Error: unsafe value used in a resource URL context
at DomSanitizerImpl.sanitize
So what I’ve tried to do is something like this:
import { DomSanitizer } from '@angular/platform-browser';
...
constructor(public sanitizer: DomSanitizer)
....
addVideo(){
let prompt = this.alertCtrl.create({
title: 'Video Information',
message: 'Enter link to video.',
inputs: [
{
name: 'link',
placeholder: 'Link'
}
],
buttons: [
{
text: 'Cancel',
handler: data => {
console.log('Item Cancelled');
}
},
{
text: 'Save',
handler: data => {
this.videos.push({
link: data.link
});
}
}
]
});
prompt.present();
}
In my html I have
<ion-grid style="color:white">
<ion-item *ngFor="let video of videos | async">
<ion-row style="color:white">
<ion-col text-center center>
<iframe width="100%" height="320" src="sanitizer.bypassSecurityTrustResourceUrl{{video.link}}"frameborder="0" allowfullscreen></iframe>
</ion-col>
</ion-row>
</ion-item>
</ion-grid>
Not sure what I’m missing