3

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.

4
  • You haven't defined ngRoute anywhere. Commented Oct 11, 2013 at 7:49
  • @BCotter ngRoute is a module coming from angular.route.js file. Commented Oct 11, 2013 at 8:49
  • The link of angular-route.min.js display "404 Not Found". Commented Oct 11, 2013 at 9:00
  • @EpokK i have the file in my local machine, can u tell me how i can add that file to this fiddle. i am knew to jsfiddle. thanx Commented Oct 11, 2013 at 9:18

1 Answer 1

8

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.

Sign up to request clarification or add additional context in comments.

3 Comments

i also tried that but it was not working, my main problem is ngRoute , i have to use it for my views routing purpose
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.
It doesn't work with just the id because it isn't a URL.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.