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.

2 Answers 2

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

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

2 Comments

You can also use $sce just the current url instead of defining a whitelist: jsbin.com/wevalile/1/edit
I just assumed he will change the url, and whitelists are best for it
0

Use ng-src:

<iframe width="100%" height="250" ng-src="http://www.youtube.com/embed/{{video.youtubeid}}" /> 

4 Comments

I added ng-src , But there is no change in it, when i simply use this {{video.youtubeid}} in <p> it gives the output path correctly as _kux-YQujjM, But in <iframe>, its not working, s there any other way.
I tried this, but I had no success... I soved my problem with this: stackoverflow.com/questions/21510891/…
This does not solve the interpolation error that Angular returns: $interpolate:interr Interpolation Error
Can't bind to 'ng-src' since it isn't a known property of 'iframe'.

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.