Boris D. Teoharov Boris D. Teoharov - 6 months ago 28
Javascript Question

use $filter service inside module.config

As per the AngularJS documentation it seems that it is only possible inject providers in

module.config
.
However, I have to configure some 3rd party service using its provider
ServiceXProvider
and set it up like this:

ServiceXProvider.format = function format(x) { return $filter('date')(x, "yyyy-MM-dd"); }


$filter
is obviously a service and not a provider and I can not inject it into the
module.config
.

Is there any reasonable workaround for this scenario?

Answer

You can update a provider object in a run() block where you can inject services