I am working on a library that extends some functions in ui.routerto create sets of application states. I am currently managing this by defining a new provider in my library (call him enhancedState) in the form:
myApp.provider('enhancedState', EnhancedState);
EnhancedState.$inject = ['$stateProvider'];
function EnhancedState ($stateProvider) {
this.$stateProvider = $stateProvider;
}
EnhancedState.prototype = {
$get: ['$state', function ($state) {
return $state;
}
};
Then I can use mine enhancedStateProviderin my application configuration to make fun new state definitions, following the advanced features of my library.
I would prefer, however, to decorate the class directly $stateProvider. I know the Angular utility $provider.decorate(), but, as far as I can tell, it can only be used to decorate created instances of the service, not the provider.
Has anyone successfully used it to decorate suppliers or is aware of a similar mechanism for this in Angular 1.x?
!