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 257 forks source link

Added compatibility for an array as a promise #35

Closed johngeorgewright closed 9 years ago

johngeorgewright commented 10 years ago

Until now we could only except an object with a promise property or an array of promises. What I need to achieve is using angular-busy with an array with a promise property.

This commonly happens when using angular's $resource service and the server responds with an array rather than an object.

function BlogFactory($resource) {
  return $resource.service('/blogs');
}

function BlogCtrl(Blog, $scope) {
  $scope.blogs = Blog.query();
}

When we use syntax like this we get an array with a promise property. A bit like doing this:

$scope.blogs = [];
$scope.blogs.$promise = $q.defer().promise;
cgross commented 10 years ago

Thanks for the pull request but why not simply pass the $promise to cg-busy? Something like:

<div cg-busy="blogs.$promise">
johngeorgewright commented 10 years ago

Oh yeh. Didn't think of doing that.

bartvanremortele commented 10 years ago

@cgross, using ".$promise" kind of defeats the ease of use of the directive don't you think? If it can support both promises in the form of an object as an array, why not just accept the pull request?

johngeorgewright commented 9 years ago

Been open for a while... unsure if it's needed anymore.