I am trying to get a youtube video inserted into my website with AngularJS, but I keep getting the same error:
Error: $interpolate:interr Interpolation Error
Why do I get this error and how can I get rid of it? All I want is to insert the video...
App.js
var myApp = angular.module('myApp', [
'duScroll', 'duParallax', 'angularFileUpload', 'ngRoute', 'ngSanitize'
]);
myApp.filter('youtube', ['$sce', function($sce) {
return function(val) {
var videoLink = val;
var watch = val.indexOf("?v=") + 3;
var playlist = val.indexOf('&') + 1;
if (playlist > 0) {
return $sce.getTrustedResourceUrl('//www.youtube.com/embed/' + val.substring(watch, playlist));
} else {
return $sce.getTrustedResourceUrl('//www.youtube.com/embed/' + val.substring(watch, videoLink.length));
}
};
}]);
index.jade
iframe(ng-if="story.media.video" src="{{ story.media.video | youtube }}" frameborder="0" allowfullscreen)