I am embedding YouTube video from database in Angular. If I use it directly without using database then it is working fine. But accessing it from database giving me below error.
Error: [$injector:unpr] http://errors.angularjs.org/1.3.2/$injector/unpr?p0=youtubeEmbedUrlFilterProvider%20%3C-%20youtubeEmbedUrlFilter
I searched on SO and found one question similar to this one. how to embed video link from database in iframe using angularjs
But while using the same answer I am not able to play YouTube video. Actually video doesn't appear and same error I am getting. YouTube video from db:
youtubevideo:"https://www.youtube.com/embed/c-z9M6KZs_0"
<div ng-style="{'display':youtubevideo == ''?'none':'block'}">
<iframe title="YouTube video player"
class="YouTube-player" type="text/HTML" width="350" height="194"
ng-src="{{youtubevideo| youtubeEmbedUrl}}" frameborder="0" allowfullscreen></iframe></div>
<!-- Youtube Video Above -->
Below code added in script file.
ProfileApp.filter('youtubeEmbedUrl', function ($sce) {
return function(videoId) {
return $sce.trustAsResourceUrl('https://www.youtube.com/embed/' + videoId);
};
});
What am I doing wrong?