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

Don't work for $resources with isArray=true #56

Open olimpiks opened 9 years ago

olimpiks commented 9 years ago

Work:

angular.module('app').factory('DemoFactory', function($resource) {
    return $resource('http://httpbin.org/delay/3', {}, {
        show : {
            method : 'GET'
        }
    })
});
angular.module('app').controller('DemoCtrl', function($scope, $http, DemoFactory) {
    $scope.demo = function() {
        $scope.promise = DemoFactory.show();
    };
});

Don't work - spinner is not shown:

angular.module('app').factory('DemoFactory', function($resource) {
    return $resource('</rest/service/request/array>', {}, {
        show : {
            method : 'GET', isArray:true
        }
    })
});
angular.module('app').controller('DemoCtrl', function($scope, $http, DemoFactory) {
    $scope.demo = function() {
        $scope.promise = DemoFactory.show();
    };
});
ktal90 commented 9 years ago

Make the attribute look like cg-busy="[arrayResource]" instead and it will work.

ivaaaan commented 9 years ago

Do you solve this?

I am try this:

 cg-busy="{promise:[promise].message:'Loading',backdrop:true,templateUrl:'components/angular-busy/angular-busy.html'}"

and get error: https://docs.angularjs.org/error/$rootScope/infdig?p0=10&p1=%5B%5D

jonagoldman commented 9 years ago

getting same error as @ivaaaan when trying his way

doodirock commented 9 years ago

Same issue as above. You can do cg-busy="[arrayResource]" just fine, but if you want access to your own template and try <div cg-busy="{promise:[arrayResource],templateUrl:'template.html'}"></div> you will get a digest error

ivaaaan commented 9 years ago

My solution: use cg-busy="[arrayResource]" and configure your cg-busy in module:

angular.module('your_app').value('cgBusyDefaults',{
  message:'Loading Stuff',
  backdrop: false,
  templateUrl: 'my_custom_template.html',
  delay: 300,
  minDuration: 700,
  wrapperClass: 'my-class my-class2'
});
doodirock commented 9 years ago

Perfect @ivaaaan