【问题标题】:ng-src not working with video tag in angularjsng-src 不适用于 angularjs 中的视频标签
【发布时间】:2018-10-22 23:56:15
【问题描述】:

<span ng-repeat="x in pics.files">
    <video ng-src="img/gallery_vid/{{x}}" height="200px" width="200px" class="mt-2" controls>
    </video>
</span>

ng-src 不适用于视频标签,如果有人可以帮助我,我会很高兴。 视频无法播放,我在网上搜索了解决方案 I saw this but I didn't get it。 提前致谢

【问题讨论】:

  • 您的绑定就像绑定到 src 一样。要绑定到 ng-src,您需要执行类似(未经测试)ng-src="'img/gallery_vid'+x"

标签: angularjs angularjs-directive angular-ui-router angularjs-scope angularjs-ng-repeat


【解决方案1】:

控制器:

(function() {
    'use strict';
        var app = angular.module('videoExample', []);
        app.controller('videoExampleController', ['$scope', videoExampleController]);

    function videoExampleController($scope){
       $scope.videoUrl = 'http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4';
       $scope.videoMimeType = 'video/mp4';
    }
 })();
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.3/angular.min.js"></script>
<div ng-app="videoExample" ng-controller="videoExampleController">
<span>
    <video height="300px" width="300px" class="mt-2" controls autoplay>
<source src="{{videoUrl}}" type="{{videoMimeType}}"/>Your browser does not support HTML5 video
    </video>
</span>
</div>

【讨论】:

    猜你喜欢
    • 2013-03-21
    • 2020-12-28
    • 2015-08-09
    • 2023-03-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多