[HELP] Show Iframe in ionic

I use that for youtube:

.html

<div class="video-container">
    <iframe [src]="updateVideoUrl(video.src)" frameborder="0" allowfullscreen></iframe>
</div>

.ts

import {SafeResourceUrl, DomSanitizationService} from '@angular/platform-browser';

constructor(public navCtrl: NavController, public sanitizer: DomSanitizationService) {

}

updateVideoUrl(id: string) {
        // Appending an ID to a YouTube URL is safe.
        // Always make sure to construct SafeValue objects as
        // close as possible to the input data, so
        // that it's easier to check if the value is safe.
        let dangerousVideoUrl = 'https://www.youtube.com/embed/' + id + '?rel=0&showinfo=0';
        return this.sanitizer.bypassSecurityTrustResourceUrl(dangerousVideoUrl);
}
5 Likes