auto.$provide.decorator()

decorator(name, decorator);

Register a service decorator with the $injector. A service decorator intercepts the creation of a service, allowing it to override or modify the behavior of the service. The object returned by the decorator may be the original service, or a new service object which replaces or wraps and delegates to the original service.

Parameters

Param Type Details
name string

The name of the service to decorate.

decorator function()Array.<(string|function())>

This function will be invoked when the service needs to be instantiated and should return the decorated service instance. The function is called using the injector.invoke method and is therefore fully injectable. Local injection arguments:

  • $delegate - The original service instance, which can be monkey patched, configured, decorated or delegated to.
doc_AngularJS
2016-03-29 16:11:04
Comments
Leave a Comment

Please login to continue.