Skip to content

Instantly share code, notes, and snippets.

@F1LT3R
Last active August 29, 2015 14:24
Show Gist options
  • Select an option

  • Save F1LT3R/b8ebd5cb39a75d286127 to your computer and use it in GitHub Desktop.

Select an option

Save F1LT3R/b8ebd5cb39a75d286127 to your computer and use it in GitHub Desktop.
app.controller('MyController', ['$rootScope', function($rootScope) {
$rootScope.$on('$stateChangeStart', function (event, toState) {
usSpinnerService.spin('spinner-1');
});
$rootScope.$on('$stateChangeSuccess', function (event, toState) {
usSpinnerService.stop('spinner-1');
});
$rootScope.$on('$stateChangeError', function (event, toState) {
usSpinnerService.stop('spinner-1');
});
}]);
@thineshbabu
Copy link
Copy Markdown

Hi F1LT3R,
It is not working and not giving any error also. Do i need to add anything in the html page apart from this codes?

@F1LT3R
Copy link
Copy Markdown
Author

F1LT3R commented Jul 10, 2015

What happens when you console.log in the stateChangeStart event?

 $rootScope.$on('$stateChangeStart', function (event, toState) {
    console.log('STATE CHANGE START');
    console.log(event);
  });

@thineshbabu
Copy link
Copy Markdown

nothing is printed
can you post me the full implementation?

@thineshbabu
Copy link
Copy Markdown

it worked with below code
$rootScope.closeAlert = function(index) {
$rootScope.alerts.splice(index, 1);
};

$rootScope.$on('$routeChangeStart', function () {
    usSpinnerService.spin('pageLoaderSpinner');
 });

 $rootScope.$on('$routeChangeSuccess', function (event, next, current) {
    usSpinnerService.stop('pageLoaderSpinner');
 });

 $rootScope.$on('$routeChangeError', function (event, next, current) {
    usSpinnerService.stop('pageLoaderSpinner');
 });

thanks for your help.

@F1LT3R
Copy link
Copy Markdown
Author

F1LT3R commented Jul 10, 2015

No problem, glad you found something that worked for you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment