0
homeApp.controller('BannerSliderController',function($scope,$timeout,$http) {
 $scope.images=$http.get().then(function(response){
  reutrn response;
});    
       $scope.currentIndex=0;
        $scope.next=function(){
            $scope.currentIndex<$scope.images.length-1?$scope.currentIndex++:$scope.currentIndex=0;
        };
        $scope.prev=function(){
            $scope.currentIndex>0?$scope.currentIndex--:$scope.currentIndex=$scope.images.length-1;
        };
        $scope.$watch('currentIndex',function(){
            $scope.images.forEach(function(image){
                image.visible=false;
            });
            $scope.images[$scope.currentIndex].visible=true;
        });
        /* Start: For Automatic slideshow*/
        var timer;
        var sliderFunc=function(){
            timer=$timeout(function(){
                $scope.next();
                timer=$timeout(sliderFunc,500);
            },5000);
        };
        sliderFunc();
        $scope.$on('$destroy',function(){
            $timeout.cancel(timer);
        });

  });

I need to use the http response globally can someone help my code run.................i used all possible solution.Thanks in advance

Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567
  • Also, `$scope.images` will be assigned a promise, not an array – Phil Feb 27 '17 at 05:48
  • i get the response after the page loads.i want it before the page laods. and it should be globally used for all controller can you make a breif!@Phil – ganesh balajii Feb 27 '17 at 07:43

0 Answers0