Tutorial by Examples

Below is example of service decorator, overriding null date returned by service. angular.module('app', []) .config(function($provide) { $provide.decorator('myService', function($delegate) { $delegate.getDate = function() { // override with actual date object return new Date(...
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 Directive suffix (case sensitive). So, if directive is called myDate, it can be...
When decorating filters, name parameter must include Filter suffix (case sensitive). If filter is called repeat, decorator parameter is repeatFilter. Below we'll decorate custom filter that repeats any given string n times so that result is reversed. You can also decorate angular's build-in filters ...

Page 1 of 1