Angular JS dynamic ng-src not working in 1.2.0-rc.2


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">

   <script src=""></script>

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

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

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:

Error: [$interpolate:noconcat] Error while interpolating:{{file}} Strict Contextual Escaping disallows interpolations that concatenate multiple expressions when a trusted value is required.  See [$sce][1]$interpolate/noconcat?
    at $interpolate (
    at attrInterpolateLinkFn (
    at nodeLinkFn (
    at compositeLinkFn (
    at nodeLinkFn (
    at compositeLinkFn (
    at compositeLinkFn (
    at publicLinkFn (
    at <video controls="" ng-src="{{file}}"> angular.js:7861

this article explains what is going on and how to disable the Strict Contextual Escaping:$sce

Answered By – akonsu

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published