gpt4 book ai didi

javascript - angularjs无法将变量分配给html5视频src

转载 作者:行者123 更新时间:2023-12-03 05:27:58 24 4
gpt4 key购买 nike

插入时出现错误: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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com