I am brand new to angular.
I have been trying many things to get embed YouTube videos into my new AngularJS site. I have a json array of video info that I am able to output in a loop.
I want to output the video ids and make create embedded videos. It's not working.
What am I doing wrong here? Why can I not just output the video id in the iframe?
'use strict';
angular.
module('showVideo').
component('showVideo', {
templateUrl: 'show-video/show-video.template.html',
controller: function ShowVideoController() {
this.videos = [
{
name: 'Rush - Kid Gloves - Guitar Solo Cover - 50% speed',
videoid: 'c-8OsVuqoCg'
},
{
name: 'Van Halen - Unchained - Guitar Cover',
videoid: 'Z9n0oIBz8SE'
},
{
name: 'Extreme - More Than Words - Guitar Cover',
videoid: 'gMJcE4kWelE'
}
];
}
});
<div ng-repeat="video in $ctrl.videos">
<span>{{video.name}}</span>
<span>{{video.videoid}}</span>
<!-- this works as expected -->
<iframe type="text/html" width="640" height="360"
ng-src="https://www.youtube.com/embed/Z9n0oIBz8SE" frameborder="0" allowfullscreen></iframe>
<!-- this does not work -->
<iframe type="text/html" width="640" height="360"
ng-src="https://www.youtube.com/embed/{{video.videoid}}" frameborder="0" allowfullscreen></iframe>
</div>
--- update
I expected to see something when I dumped these values. I see nothing though.
<h1>{{$sce.isEnabled()}}</h1>
<h1>{{encodeURI(video.videourl)}}</h1>
<h1>{{$sce.trustAsUrl(video.videourl)}}</h1>
<h1>{{$sce.RESOURCE_URL(video.videourl)}}</h1>