I've created a basic Angular page that takes an ID (a guid) from the URL and uses the ID to feed into an API call. I've done similar pages in the past that have worked with no issue. But for some reason this one doesn't seem to want to play ball when it comes to the You Tube video.
When I output the You Tube URL to the console it's displayed with no issue, however when I sanitise it and post the URL to the src property of the iframe embed it does not display. However (and this is where it gets weird) if I change the description from the API from {{session?.SessionDescription}}
to {{session.SessionDescription}}
, the video is displayed.
The description text loads no matter which of those I use. But if I don't include the question mark I get a console error that the description can't be loaded even though it's on the screen.
I just want both to load with no console errors if possible.
HTML:
<nav class="pure-drawer" data-position="left">
<h1>What is 3D Printing?</h1>
<p>{{session?.SessionDescription}} {{session?.SessionGains}}</p>
</nav>
<div class="pure-pusher-container">
<div class="pure-pusher">
<!-- Copy & Pasted from YouTube -->
<iframe width="560" height="349" [src]="vidUrl" frameborder="0" allowfullscreen></iframe>
</div>
</div>
Typescript:
getCurrentSession(){
this.sub = this.route.params.subscribe(params => {
this.id = params['id'];
this._wmapi
.getService("Session/" + this.id)
.then((result) => {
this.session = result;
this.vidUrl = this.sanitizer.bypassSecurityTrustResourceUrl(result.SessionVideo);
this.getSessionResources(this.id);
})
.catch(error => console.log(error));
});
}
*ngIf="vidUrl"
iniframe
tag? – shhdharmen