Skip to content Skip to sidebar Skip to footer

Self Rotating Image Using Angularjs

I am trying to create a self rotating image viewer in AngularJS. Sorry if the question seems stupid, but I can't figure it out the angularJS way. I know I can hack it there using j

Solution 1:

You have to add a loop in your controller.

app.controller('rotatorController', ['$scope', '$timeout', function($scope, $timeout) {
  $scope.pic = 1;

  var slideImage = function() {
    var loop = $timeout(functionchangePic() {
        if($scope.pic < 2){
          $scope.pic++;
        } else {
          $scope.pic = 1;
        }
        loop = $timeout(changePic, 2000);
    },2000);
  }();

}])  

Here is the plunker

Post a Comment for "Self Rotating Image Using Angularjs"