插入时出现错误:videos/{{video.name}}
,代码如下:
<div ng-repeat='video in videos'>
<div class="col-md-3">
<video controls>
<source src="videos/{{video.name}}" type="video/mp4">
Your browser does not support HTML5 video.
</video>
{{video.name}} // this worked
</div>
</div>
也尝试过 ng-src 但不起作用。奇怪的。
最佳答案
使用此过滤器,
app.filter("trustUrl", ['$sce', function ($sce) {
return function (recordingUrl) {
return $sce.trustAsResourceUrl(recordingUrl);
};
}]);
HTML
<video controls>
<source src="videos/{{video.name | trustUrl}}" type="video/mp4">
Your browser does not support HTML5 video.
</video>
关于javascript - angularjs无法将变量分配给html5视频src,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41077824/