Adding Ajax loader in angular ui bootstrap modal

2019-07-19 12:13发布

问题:

I have ui bootstrap modal to play videos, these videos are taking time to load so i want to show ajax loader until videos get loaded.

here is my ng-template and angular js code for modal, I have added ajax loader but i am not getting how to stop its loading. I want to stop its loading when videos are completely loaded. thanks

 <script type="text/ng-template" id="video_gallery.html">
  <div class="modal-content col-md-12" >
    <div class="modal-header">
      <h4 class="modal-title" style="text-align:center;">Videos of {{hall_videos[0].hall_name}} Hall</h4>
    </div>
    <div class="modal-body " >
    <div ng-if="hall_videos==0">
      <h4 style="font-weight:bold;font-family:Bitstream Charter;">Sorry! No Videos Found to Display.</h4>
    </div>
    <div  class="col-md-4 col-md-offset-0" ng-repeat = "video in hall_videos" class="col-md-8">
      <h5>Video Name: {{video.video_name}}</h5>
      <div>
        <img id="spn"  ng-src="<?=base_url()?>images/ajax-loader.gif"  style="position: absolute;left: 35%;top: 45%;"></img>
        <iframe  allowfullscreen="true" webkitallowfullscreen="true" mozallowfullscreen="true" id="player" type="text/html" width="200" height="200"
           src="//www.youtube.com/embed/{{video.video_code}}" frameborder="2">
        </iframe>
      </div>
    </div>
  </div>
  <div class="col-md-12"><br><br></div>
</div>
  <div class="modal-footer"><br>
    <div class=" ">
      <a href="<?=base_url()?>hall/calender/{{hall_videos[0].hall_info_id}}"><button class='btn btn-success'>Book Now</button></a>
      <button class="btn btn-warning" ng-click="cancel()">cancel</button>
    </div>
  </div>
</script>

and here is my js code for modal

 $scope.open = function (size, id) {
  $scope.hall_videos = hall_videos;
  var modalInstance = $modal.open({
    templateUrl: 'video_gallery.html',
    controller: HomeCtrl1,
    size: size,
      backdrop: true,
    resolve: {
      videos: function () {
        var videos = [];
        angular.forEach($scope.hall_videos, function(video) {
          if (video.hall_info_id === id) {
            videos.push(video);
          }
        });
        return videos;
      }
    }
  });
};
var HomeCtrl1 = function ($scope, $modalInstance, videos) {
  $scope.hall_videos = videos;
  $scope.selected = {
    hall_videos: $scope.hall_videos
  };
  $scope.ok = function () {
    $modalInstance.close($scope.selected.hall_videos);
  };
  $scope.cancel = function () {
    $modalInstance.dismiss('cancel');
  };
};