我正在使用angularJS,我正在尝试在列表中显示视频,为此我写了以下几行,但我无法获得链接:
<div ng-repeat ='video in vm.videos'>
<video width="400" controls>
<source ng-src="videos/{{video.video}}" type="video/mp4">
Your browser does not support this video.
</video>
<source src="videos/{{video.video}}" type="video/mp4">
</div>
当我将该名称视为静态时,它会显示我的视频,有人可以提供帮助吗?
"videos": [
{
"_id": "587f5d31ceb2891e31422481",
"title": "DSDAXAXASXASSX",
"text": "<p>ASXASXASXASXASX</p>",
"correlated_duione": "D008133",
"correlated_duitwo": "ASXASXS",
"video": "loading.-1484741937856.png,",
"__v": 0
}
],
答案 0 :(得分:1)
您的代码语法错误很少:
<div ng-repeat ='video in vm.videos>
你错过了最终报价。试试这个:
<div ng-repeat ="video in vm.videos">
除此之外,它看起来是正确的。如果它不起作用,请在浏览器中打开开发人员控制台,查看是否记录了任何HTTP错误。很可能,您提供的videos/{{video.video}}
链接已损坏。
答案 1 :(得分:0)
//In your MODULE add a filter (change "myModule" with the proper name )
myModule.filter('videoUrl', function($sce) {
return function(video) {
return $sce.trustAsResourceUrl(video.video);
};
});
<!--In your view-->
<div ng-repeat ='video in vm.videos'>
<video width="400" ng-src="{{ video | videoUrl }}" controls></video>
</div>