Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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');
  };
};
share|improve this question
    
Does it have anything to do with modals? Or rather iframes and their src attribute? –  pkozlowski.opensource Jun 5 at 14:21
    
Sorry sir I am not getting you. Actually I am new to angular js. I am getting ajax loader img(spinning) but when video is loaded completely that img still keeps spinning so any idea to hide it or close it once the requested video is loaded completely.? –  Sudarshan Jun 5 at 14:26
    
You can try to use onload (or jQuery load) on an iframe and hide your ajax indicator there. –  jcubic Jul 5 at 8:58
    
I tried using JQuery but its not working sir.. –  Sudarshan Jul 5 at 9:22
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.