Open jrencz opened 6 years ago
Totally agree. In the mean time, we can work around the issue by using $injector
to get uiMask.ConfigProvider
.
angular
.module('myModule')
.config($injector => {
'ngInject';
const uiMaskConfigProvider = $injector.get("uiMask.ConfigProvider");
Object.keys(uiMaskConfigProvider) // ['$get', 'maskDefinitions', 'clearOnBlur'...]
})
$injector
is a service. It won't be available in the config phase
It's what I thought originally. I'm not really understand the way Angular work myself, but the above code is working. And it seems there are 2 different, separate $injector
in angular, one is responsible for injecting the providers, one is for services.
More detail here: https://github.com/angular/angular.js/issues/5559
I also did a test, if you inject an $injector
in the config
block, and compare that with the $injector
you get from all other controller (including the run
block), you will find that the $injector
in the config
block is different from all the others (all controllers get the same $injector
, but not the config
block).
Name of registered provider is
uiMask.Config
so in config blocks it has to be referred to asuiMask.ConfigProvider
.This limits the possibilities of accessing it in config blocks to explicit annotation like this:
but an attempt to use implicit annotation (and possibly ng-annotate or its successor babel-plugin-angularjs-annotate) fails:
To be able to do that
uiMask.Config
should becomeuiMaskConfig
. But thenuiMaskConfig
(value) has to be renamed or provider has to produce the value (which I was certain it did, but it turns out thatuiMaskConfig
anduiMask.Config
are 2 distinct DI entities)I suggest
uiMaskConfig
should becomeuiMaskConfigDefaults
anduiMask.Config
should be renamed touiMaskConfig
.It's a breaking change, yet one easy to guide the users through.