Adding Ajax loader in angular ui bootstrap modal

回眸只為那壹抹淺笑 提交于 2019-12-12 21:41:10

问题


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');
  };
};

来源:https://stackoverflow.com/questions/24061341/adding-ajax-loader-in-angular-ui-bootstrap-modal

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!