HTML5 视频不适用于 AngularJS ng-src 标签
问题描述:
AngularJS ng-src
不适用于此小提琴中的 HTML5 Video 元素:http://jsfiddle.net/FsHah/5/
AngularJS ng-src
doesn't work with HTML5 Video element in this fiddle: http://jsfiddle.net/FsHah/5/
查看 video 元素,src 标记填充了正确的 src uri,但视频无法播放.
Looking at video element, the src tag is being populated with the correct src uri, but the video doesn't play.
这在 不支持?/forum/?fromgroups=#!topic/angular/oaSFYtWINzE">AngularJS,有什么解决方法?
Is this not supported in AngularJS, what is the workaround for this?
答
只需创建一个过滤器:
app.filter("trustUrl", ['$sce', function ($sce) {
return function (recordingUrl) {
return $sce.trustAsResourceUrl(recordingUrl);
};
}]);
在查看文件中:
<audio src="{{Your_URL | trustUrl}}" audioplayer controls></audio>