0

I'm trying to play sound, if i use link to sound like this:

<audio controls ng-src="http://playerdemo.iainhouston.com/tests/BeBopAliens.mp3"></audio>

It's Ok, but when i try use link from $scope.audioArray like this:

<div ng-repeat="au in audioArrray">
  <audio controls ng-src="{{au.link"}}> </audio>
</div>


$scope.audioArray = [
{
   id: 1,
   link: "http://playerdemo.iainhouston.com/tests/BeBopAliens.mp3"
}];

it's doesn't play,I done the Plunker Example. Maybe somebody knows how i can resolve it ? Thanks for your answers!

Uladz Kha
  • 2,154
  • 4
  • 40
  • 61

1 Answers1

1

This is the error you get:

Can't interpolate: {{au.link}} Error: [$sce:insecurl] http://errors.angularjs.org/1.5.7/$sce/insecurl?p0=http%3...

It basically means that the interpolation has failed due to an untrusted resource you were passing.

More on this issue here: https://docs.angularjs.org/api/ng/service/$sce

Try this:

var myApp = angular.module("myApp",[]);
myApp.controller("defCtrl", function($scope, $sce){
  $scope.audioArray = [
    {
      id: 1,
      link: $sce.trustAsResourceUrl("http://playerdemo.iainhouston.com/tests/BeBopAliens.mp3")
    }];
});
AranS
  • 1,871
  • 10
  • 22