| Start |
|---|
| Decorate service, factory Below is example of service decorator, overriding |
| Decorate directive Directives can be decorated just like services and we can modify or replace any of it's functionality. Note that directive itself is accessed at position 0 in $delegate array and name parameter in decorator must include So, if directive is called Below is simple example where directive shows current time. We'll decorate it to update current time in one second intervals. Without decoration it will always show same time. |
| Decorate filter When decorating filters, name parameter must include Syntax
Remarks**Decorator** is function that allow a [service](http://stackoverflow.com/documentation/angularjs/5169/providers/18267/service#t=201608041619054034455), [factory](http://stackoverflow.com/documentation/angularjs/5169/providers/18266/factory#t=201608041619527352795), [directive](http://stackoverflow.com/documentation/angularjs/965/custom-directives#t=201608041536457908389) or [filter](http://stackoverflow.com/documentation/angularjs/1401/filters#t=201608041537025734034) to be modified prior to its usage. Decorator is used to override or modify the behavior of the service. The return value of the decorator function may be the original service, or a new service that replaces, or wraps and delegates to, the original service. Any decorating must be done in angular application's The decorator function has a `$delegate` object injected to provide access to the service that matches the selector in the decorator. This `$delegate` will be the service you are decorating. The return value of the function provided to the decorator will take place of the service, directive, or filter being decorated. One should consider using decorator only if any other approach is not appropriate or proves to be too tedious. If large application is using same service, and one part is changing service behavior, it's easy to create confusion and/or bugs in the process. Typical use case would be when you have a 3rd party dependency which you can't upgrade but need it to work little differently or extend it. |
Read Article
https://develop.horje.com/learn/1434/reference