我无法使用angularjs加载div中的视频

时间:2016-01-21 09:28:19

标签: angularjs

我能够在div中加载一个视频,但它正在被隐藏。我想在此特定div中使用angularjs加载所有视频。 在我的html页面中,下面的div被隐藏了。我不知道为什么会这样。

div ng-show="videoSources.length">
                    <video width=176 height=99
                        style="margin-left: 70px; margin-right: 10px;"
                        ng-repeat="videoSource in videoSources | paginate:pageNum:pageSize track by $index"
                        controls ng-src="{{videoSource | trustUrl}}">
                    </video>

                    <button style="margin-left: -1041px" ng-disabled="isFirstPage()"
                        ng-click="prevPage()">Previous</button>
                    <button style="margin-left: 977px" ng-disabled="isLastPage()"
                        ng-click="nextPage()">Next</button>
                </div>

任何人都可以帮我解决这个问题...

我的index.html:

<div class="container-fluid" ng-controller="videocontroller">
    <div class="panel panel-default">
        <div class="panel-heading">
            <h3>
                <b>Video Segment</b>
            </h3>
        </div>
        <div class="panel-body">
                <div ng-show="videoSources.length">
                    <video width=176 height=99
                        style="margin-left: 70px; margin-right: 10px;"
                        ng-repeat="videoSource in videoSources | paginate:pageNum:pageSize track by $index"
                        controls ng-src="{{videoSource | trustUrl}}">
                    </video>

                    <button style="margin-left: -1041px" ng-disabled="isFirstPage()"
                        ng-click="prevPage()">Previous</button>
                    <button style="margin-left: 977px" ng-disabled="isLastPage()"
                        ng-click="nextPage()">Next</button>
                </div>
                <div ng-hide="videoSources.length">
                    <a href="#" ng-click='loadVideos()'>Load videos</a>
                </div>

            </div>

        </div>

            </div>

我的script.js:

app.controller('videocontroller', function($scope) {

  $scope.pageNum = 0;
  $scope.pageSize = 4;
  $scope.isFirstPage = function() {
    return $scope.pageNum === 0;
  };
  $scope.isLastPage = function() {
    return $scope.pageNum >= Math.floor($scope.videoSources.length / $scope.pageSize);
  };
  $scope.prevPage = function() {
    $scope.pageNum--;
  };
  $scope.nextPage = function() {
    $scope.pageNum++;
  };

  $scope.videoSources = [];
  $scope.loadVideos = function() {
    for (var i = 0; i < 6; i++) {
         $scope.videoSources.push('http://54.88.118.248/Video/Digital_Hiring.mp4');
         $scope.videoSources.push('http://54.88.118.248/Video/Customer_Service.mp4');
         $scope.videoSources.push('http://54.88.118.248/Video/Digital_Hiring.mp4');
         $scope.videoSources.push('http://54.88.118.248/Video/Digital_Hiring.mp4');
         $scope.videoSources.push('http://54.88.118.248/Video/Customer_Service.mp4');
         $scope.videoSources.push('http://54.88.118.248/Video/Digital_Hiring.mp4');
    }
  };
})
.filter("trustUrl", ['$sce',
  function($sce) {
    return function(recordingUrl) {
      return $sce.trustAsResourceUrl(recordingUrl);
    };
  }
])
.filter('paginate', function() {
  console.log('creating paginate function', arguments);
  return function(inputArray, pageNumber, pageSize) {
    console.log('paginating', arguments);
    pageNumber = pageNumber || 0;
    pageSize = pageSize || 4;
    if (!Array.isArray(inputArray)) return inputArray;
    return inputArray.slice(pageNumber * pageSize, (pageNumber + 1) * pageSize);
  };
});

0 个答案:

没有答案