angularjs中动态为audio绑定src
2019-08-09 本文已影响0人
w_wx_x
1.常见audio的使用
<audio src="/i/horse.ogg" controls="controls">
Your browser does not support the audio element.
</audio>
2.angular.js中的绑定
需要在对应的control中添加sce.trustAsResourceUrl(url)处理,进行绑定即可
var feedBackCtrl = function($scope,$sce){
$scope.sce = $sce.trustAsResourceUrl;
$scope.audioList = [{
contentType: "audio/mpeg",
entityId: 179,
entityType: 600,
fileName: "audio.mp3",
id: 89,
size: 61620,
src: "https://dev.gcb365.com/api/web/file/download?uuid=df572046-d0e5-3b23-baef-142a1486af85",
time: 5
}]
}
<div class="comment-audio" ng-repeat="audio in audioList track by $index">
<audio controls="controls" ng-src="{{sce(audio.src)}}"></audio>
</div>