cgross / angular-busy

Show busy/loading indicators on any element during $http requests (or any promise).
http://cgross.github.io/angular-busy/demo
MIT License
1.44k stars 256 forks source link

Version 4.* and angular-ui-router resolve #36

Open Ludevik opened 10 years ago

Ludevik commented 10 years ago

Hello, i was using older version of angular-busy which had a dependency on angular-promise-tracker. Older version integrated nicely with angular-ui-router's resolve functionality. I just added the tracker to $http option object and that was it. Every request was tracked and busy div popped up.

The question is how to use the new version with angular-ui-router resolve. New version tracks promises added to the $scope, but as i am using ui-router's resolve functionality, resolved promises are injected to my controller. I am not creating any promises in my controller, so i cannot add them to $scope.

Thanks L

quocnguyen commented 9 years ago

+1

lostb1t commented 9 years ago

+1

gkohen commented 9 years ago

+1

doodirock commented 9 years ago

+2 A large majority of apps are moving toward using resolves via router. Would love to be able to include this option with angular-busy

cgross commented 9 years ago

Is the use-case to just show a spinner during route loads? If so, you could use the $stateChangeStart/Success/Error events. Something like:

var defer;
$rootScope.$on('$stateChangeStart',function(){
   defer = $q.defer();
   $rootScope.busyPromise = defer.promise;
});

$rootScope.$on('$stateChangeSuccess', function(){
   defer.resolve();
});

$rootScope.$on('$stateChangeError', function(){
   defer.reject();
});
axelson commented 8 years ago

Thanks @cgross that works great for me.