Why this jsfiddle is not working? I am not able to get value of videoId. If I remove ngRoute from module then it is working fine.
1 Answer
You need to use ng-src like this:
<div ng-controller="AppController">
<h1>{{videoID}}</h1>
<iframe class="youtube-player" type="text/html" width="auto"
height="auto" ng-src="{{videoID}}"
allowfullscreen="" frameborder="0"> </iframe>
</div>
and
var app = angular.module('my-app', []);
app.controller('AppController', function ($scope, $sce) {
$scope.videoID = $sce.trustAsResourceUrl('http://www.youtube.com/embed/C0DPdy98e4c');
});
See this documentation.
3 Comments
ARV
i also tried that but it was not working, my main problem is ngRoute , i have to use it for my views routing purpose
ARV
I tried $scope.videoID = $sce.trustAsResourceUrl('C0DPdy98e4c'); but it didn't work and then i use $sce.trustAsResourceUrl("youtube.com/embed/C0DPdy98e4c"); then it worked, i dont know why it is not working with only id, but i am accepting your answer.
Ryan Schumacher
It doesn't work with just the id because it isn't a URL.
angular-route.min.jsdisplay "404 Not Found".