0

I am using AngularJS, and have the following template:

<view title="'Watch ' + movie.title">
  <content has-header="true" padding="true">
    <video width="100%" height="auto" controls>
      <source src="video/{{ movie.id }}.mp4" type="video/mp4">
    </video>
  </content>
</view>

When I try and run it I get the error Error while interpolating: video/{{ movie.id }}.mp4 Strict Contextual Escaping disallows interpolations that concatenate multiple expressions when a trusted value is required. However, I have no problems putting {{ movie.id }} as text below in a button or anything else, so what's wrong?

Benedict Lewis
  • 2,733
  • 7
  • 37
  • 78
  • 2
    I googled that error and found this: [Angular JS dynamic ng-src not working in 1.2.0-rc.2](http://stackoverflow.com/questions/19372300/angular-js-dynamic-ng-src-not-working-in-1-2-0-rc-2) - Ignore the marked answer and look at the most upvoted one instead, it explains the problem – CodingIntrigue Mar 03 '14 at 12:39

2 Answers2

0

I guess you should use ng-src directive here: ng-src="video/{{ movie.id }}.mp4" http://code.angularjs.org/1.2.14/docs/api/ng/directive/ngSrc

Goodnickoff
  • 2,267
  • 1
  • 15
  • 14
  • can you show an example in plunker? Maybe you should use `$sce.trustAsResourceUrl`? http://code.angularjs.org/1.2.14/docs/api/ng/service/$sce e.g. `videoUrl = $sce.trustAsResourceUrl('video/'+movie.id);` – Goodnickoff Mar 03 '14 at 12:43
0

A work around could be

ng-init="myurl = movie.id + '.mp4'"
Whisher
  • 31,320
  • 32
  • 120
  • 201