2

I am trying to Embed the url link from a Json to angularJs.

Now i have the {{video.youtubeid}} with the output in Json controller has _kux-YQujjM

But when i use to call this function inside <iframe>, it is not working.

when i use this function inside P tag it show the output as _kux-YQujjM

This is my code used with iframe tag.

<iframe width="100%" height="250" src="//www.youtube.com/embed/{{video.youtubeid}}" frameborder="0" allowfullscreen=""></iframe>

Whether i missed anything in my code or Is there any way to get the url to connect with this link.

Any help will be Appreciated.

KesaVan
  • 1,031
  • 16
  • 32

2 Answers2

4

It's beceuse of SCE that don't allow you for constructs like 'something{{myModelValue}}' although you should configure SCE to allow youtube access

.config(function($sceDelegateProvider) {
   $sceDelegateProvider.resourceUrlWhitelist([
     'self',
     '*://www.youtube.com/**'
   ]);
 });

here is a working plunker http://plnkr.co/edit/PZXy6RyiWo60KcIyYh5n?p=preview

maurycy
  • 8,455
  • 1
  • 27
  • 44
0

Use ng-src:

<iframe width="100%" height="250" ng-src="http://www.youtube.com/embed/{{video.youtubeid}}" /> 
Michael Kang
  • 52,003
  • 16
  • 103
  • 135
  • I added ng-src , But there is no change in it, when i simply use this {{video.youtubeid}} in

    it gives the output path correctly as _kux-YQujjM, But in

    – KesaVan Jul 24 '14 at 08:41
  • I tried this, but I had no success... I soved my problem with this: http://stackoverflow.com/questions/21510891/angular-ng-bind-html-doesnt-work-with-youtube-embed – herbert Jul 16 '15 at 20:39
  • This does not solve the interpolation error that Angular returns: $interpolate:interr Interpolation Error – Coded Container Jul 18 '16 at 17:51
  • `Can't bind to 'ng-src' since it isn't a known property of 'iframe'.` – prayagupa Jul 10 '17 at 20:27