Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
86
rated 0 times [  89] [ 3]  / answers: 1 / hits: 28787  / 11 Years ago, tue, october 15, 2013, 12:00:00

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



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>


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)


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


More From » angularjs

 Answers
193

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


Error: [$interpolate:noconcat] Error while interpolating: http://www.thebigdot.com/{{file}} Strict Contextual Escaping disallows interpolations that concatenate multiple expressions when a trusted value is required.  See [http://docs.angularjs.org/api/ng.$sce][1] 

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 <video controls="" ng-src="http://www.thebigdot.com/{{file}}"> angular.js:7861

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


[#74990] Sunday, October 13, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
jarod

Total Points: 62
Total Questions: 111
Total Answers: 83

Location: Saint Vincent and the Grenadines
Member since Sat, Sep 11, 2021
3 Years ago
jarod questions
;