美文网首页
angularjs中动态为audio绑定src

angularjs中动态为audio绑定src

作者: w_wx_x | 来源:发表于2019-08-09 11:26 被阅读0次

    1.常见audio的使用

    <audio src="/i/horse.ogg" controls="controls">
      Your browser does not support the audio element.
    </audio>
    

    2.angular.js中的绑定
           需要在对应的control中添加sce &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;使用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>
    

    相关文章

      网友评论

          本文标题:angularjs中动态为audio绑定src

          本文链接:https://www.haomeiwen.com/subject/oapcjctx.html