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

Unknown provider: cgBusyDefaults #109

Open simonemazzoni opened 7 years ago

simonemazzoni commented 7 years ago

Hello @cgross, tried right now to update the module using this library. Previously I had to use https://github.com/tiberiuzuld/angular-busy because this project looked unmaintained.

Except the fact that install it from npm is a real mess (due to several versions with different names!), I finally managed to install the correct version but it gives me this error when I try to set the config provider.

Uncaught Error: [$injector:modulerr] Failed to instantiate module myApp due to: Error: [$injector:unpr] Unknown provider: cgBusyDefaults

I really don't understand why. I checked the source code and the provider extension actually exists, but the error exists too. Notice I am using Angularjs 1.5.9

Let me know asap. Thanks

Simone

geo242 commented 7 years ago

@simonemazzoni This error seems like it could be that the library is either not being loaded, or not being loaded before your module is instantiated. Have you checked both of those things?

simonemazzoni commented 7 years ago

@geo242 thanks for the answer, but I don't think it is a load problem.

I found out that the correct way to define defaults config is this: 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' });

So it isn't exposed a provider as in other angular modules. That's my error.

Anyway I think that implement and export a provider would be preferable, at least in my opinion.

geo242 commented 7 years ago

@simonemazzoni Sorry, I missed the fact that you were looking for a config provider. You can either use the method you describe, or inject the cgBusyDefaults into a run block and manipulate it there.

Setting the defaults in a provider sounds like a good candidate for a PR. :)

simonemazzoni commented 7 years ago

@geo242 Yes, I can think about it as soon I find some time. ;)

Please leave this open so that me or someone knows it has to be done.