在IFRAME角JS范围VAR值 [英] Angular js scope var value in iframe

查看:139
本文介绍了在IFRAME角JS范围VAR值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我与JS角工作。我有一个控制器youTubePlayerCtrl,在这个控制器我有$ scope.videoID包含YouTube视频ID。我能够在H1块获得初级讲座DIV此值。但我不能够得到{{VIDEOID}}在iframe中,任何一个可以帮助我如何解决这个问题。

I am working with angular js . I have a controller "youTubePlayerCtrl", in this controller i have $scope.videoID which contains the youtube video id. I am able to get this value in belows div in h1 block . but i am not able to get {{videoID}} in iframe, can any one help me how to fix this.

<div ng-controller="youTubePlayerCtrl">
    <h1>{{videoID}}</h1>
    <iframe class="youtube-player" type="text/html" width="auto"
        height="auto" src="http://www.youtube.com/embed/{{videoID}}"
        allowfullscreen frameborder="0"> </iframe>
</div>

这是错误日志:

[$插值:noconcat]
  的http://errors.angularjs.org/undefined/$interpolate/noconcat?p0=http%3A%2F%2Fwww.youtube.com%2Fembed%2F%7B%7BvideoID%7D%7D
      在错误()
      在的http:// code.angularjs.org/1.2.0-rc.2/angular.min.js:6:453
      在克(的http:// code.angularjs.org / 1.2.0-rc.2 / angular.min.js:69:467
      在b.push.compile( HTTP ://$c$c.angularjs.org/1.2.0-rc.2/angular.min.js:54:6
      在L(的http:// code.angularjs.org / 1.2.0-rc.2 / angular.min.js:47:124
      在f(的http:// code.angularjs.org / 1.2.0-rc.2 / angular.min.js:41:361
      在L(的http:// code.angularjs.org / 1.2.0-rc.2 / angular.min.js:47:64
      在f(的http:// code.angularjs.org / 1.2.0-rc.2 / angular.min.js:41:361
      在的http:// code.angularjs.org/1.2.0-rc.2/angular.min.js:40:434
      在的http:// code.angularjs.org / 1.2.0-rc.2 /角route.min.js:7:148 angular.js:7861(匿名
  功能)

[$interpolate:noconcat] http://errors.angularjs.org/undefined/$interpolate/noconcat?p0=http%3A%2F%2Fwww.youtube.com%2Fembed%2F%7B%7BvideoID%7D%7D at Error () at http://code.angularjs.org/1.2.0-rc.2/angular.min.js:6:453 at g (http://code.angularjs.org/1.2.0-rc.2/angular.min.js:69:467) at b.push.compile (http://code.angularjs.org/1.2.0-rc.2/angular.min.js:54:6) at l (http://code.angularjs.org/1.2.0-rc.2/angular.min.js:47:124) at f (http://code.angularjs.org/1.2.0-rc.2/angular.min.js:41:361) at l (http://code.angularjs.org/1.2.0-rc.2/angular.min.js:47:64) at f (http://code.angularjs.org/1.2.0-rc.2/angular.min.js:41:361) at http://code.angularjs.org/1.2.0-rc.2/angular.min.js:40:434 at http://code.angularjs.org/1.2.0-rc.2/angular-route.min.js:7:148 angular.js:7861 (anonymous function)

的jsfiddle (不工作)

感谢名单

推荐答案

第一:你需要使用 NG-SRC 而不是的src 作为@Cherniv在你的问题中留言建议。这里更多

First: you need to use ng-src instead of src as @Cherniv suggested in a comment to your question. Read more here.

:你不能连接源属性中的URL出于安全原因:你必须连接在Javascript URL在范围的变量如 fullURL 然后 NG-SRC ={{fullURL}}。阅读更多 href=\"https://github.com/angular/angular.js/issues/3679\">。

Second: you cannot concatenate the URL inside the source attribute for security reasons: you must concatenate the URL in Javascript in a scope variable e.g. fullURL and then ng-src="{{fullURL}}". Read more here.

第三:如果严格语境逃逸(SCE)已启用 - 和角度V1.2附带SCE默认启用的 - 你需要加入白名单的URL。阅读更多 href=\"http://docs.angularjs.org/api/ng.%24sce\">和的这里

Third: if Strict Contextual Escaping (SCE) is enabled ‒ and Angular v1.2 ships with SCE enabled by default ‒ you need to whitelist the URLs. Read more here and here.

这篇关于在IFRAME角JS范围VAR值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆