角JS动态NG-SRC在1.2.0-rc.2不工作 [英] Angular JS dynamic ng-src not working in 1.2.0-rc.2

查看:197
本文介绍了角JS动态NG-SRC在1.2.0-rc.2不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想实现的角度JS应用程序和NG-SRC视频元素不会读取范围变量

I'm trying to implement a video element in an angular JS app and the ng-src won't read the scope variable

我使用的是1.2.0-rc.2

I'm using 1.2.0-rc.2

<!DOCTYPE html>
<html ng-app="ngView">

<head>
   <script src="http://code.angularjs.org/1.2.0-rc.2/angular.min.js"></script>

   <script>
   var app = angular.module('ngView', []);
   function MyControl($scope){
      $scope.file = '1234.mp4';
   }
  </script>
  </head>
  <body ng-controller="MyControl">
      <video controls  ng-src="http://www.thebigdot.com/{{file}}"></video>
  </body>
</html>

如果我用一个更旧版本AngularJS lib中,它的工作原理。

If I use a much older version AngularJS lib, it works.

cdnjs.cloudflare.com/ajax/libs/angular.js/1.0.3/angular.min.js (works)

这是在最新版本中的bug或者有它的目的被禁用?什么是变通?

Is this a bug in the latest release or has it been disabled on purpose? What is the work around ?

推荐答案

有点调试后,我发现,错误的是这样的:

after a bit of debugging I found that the error is this:


错误:[$插值:noconcat]错误而插值: http://www.thebigdot.com/ {{文件}}
严格的语境不允许转义时,需要一个值得信赖的值,连接多个EX pressions插值。请参见 http://docs.angularjs.org/api/ng.$sce

http://errors.angularjs.org/1.2.0-rc.2/$interpolate/noconcat?p0=http%3A%2F%2Fwww.thebigdot.com%2F%7B%7Bfile%7D%7D
    在的http:// code。 angularjs.org/1.2.0-rc.2/angular.js:78:12
    在$插补(的http:// code.angularjs.org / 1.2.0-rc.2 / angular.js:6953:17
    在attrInterpolateLinkFn(的http:// code.angularjs.org/1.2.0-rc.2/angular.js:5367:27
    在nodeLinkFn(的http:// code.angularjs.org/1.2.0-rc.2/angular.js:5121:13
    在compositeLinkFn(的http:// code.angularjs.org/1.2.0-rc.2/angular.js:4640:15
    在nodeLinkFn(的http:// code.angularjs.org/1.2.0-rc.2/angular.js:5115:24
    在compositeLinkFn(的http:// code.angularjs.org/1.2.0-rc.2/angular.js:4640:15
    在compositeLinkFn(的http:// code.angularjs.org/1.2.0-rc.2/angular.js:4643:13
    在publicLinkFn(的http:// code.angularjs.org/1.2.0-rc.2/angular.js:4549:30
    在的http:// code。 angularjs.org/1.2.0-rc.2/angular.js:1157:27 angular.js:7861

http://errors.angularjs.org/1.2.0-rc.2/$interpolate/noconcat?p0=http%3A%2F%2Fwww.thebigdot.com%2F%7B%7Bfile%7D%7D at http://code.angularjs.org/1.2.0-rc.2/angular.js:78:12 at $interpolate (http://code.angularjs.org/1.2.0-rc.2/angular.js:6953:17) at attrInterpolateLinkFn (http://code.angularjs.org/1.2.0-rc.2/angular.js:5367:27) at nodeLinkFn (http://code.angularjs.org/1.2.0-rc.2/angular.js:5121:13) at compositeLinkFn (http://code.angularjs.org/1.2.0-rc.2/angular.js:4640:15) at nodeLinkFn (http://code.angularjs.org/1.2.0-rc.2/angular.js:5115:24) at compositeLinkFn (http://code.angularjs.org/1.2.0-rc.2/angular.js:4640:15) at compositeLinkFn (http://code.angularjs.org/1.2.0-rc.2/angular.js:4643:13) at publicLinkFn (http://code.angularjs.org/1.2.0-rc.2/angular.js:4549:30) at http://code.angularjs.org/1.2.0-rc.2/angular.js:1157:27 angular.js:7861

这篇文章解释了什么是怎么回事,如何禁用严格的语境转义:的http:/ /docs.angularjs.org/api/ng.$sce

this article explains what is going on and how to disable the Strict Contextual Escaping: http://docs.angularjs.org/api/ng.$sce

这篇关于角JS动态NG-SRC在1.2.0-rc.2不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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