0

I have a basic ng-repeat loop that displays my content but if I use ng-src for video tags it causes this error:

Error: [$interpolate:noconcat] Error while interpolating: http://localhost{{post.media}}

I know I can use a $sce service but I am not sure how to utilize it in the context of ng-repeat...

luiquao
  • 1,056
  • 2
  • 20
  • 45

1 Answers1

2

It has nothing to do with ngRepeat. It is Angular's SCE protecting you from a potentially unsafe practice.

1.) You could create a function in your controller that generates the URL:

var host = 'http://localhost/';
$scope.generateURL = function (media) {
    return host + media;
};

2.) Then, call it from the view:

... ng-src="{{generateURL(post.media)}}"

Take a look at this answer for more info on why the error occurs and what is SCE's purpose.

Community
  • 1
  • 1
gkalpak
  • 47,117
  • 8
  • 102
  • 117