Skip to content

henrytao-me/angular-decorate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

angular-decorate

Use AngularJS' decorate function with ease.

Removes the boilerplate code needed to decorate a service, so that you can decorate any service with this simple function call:

angular.module(moduleName).decorate(serviceName, decorateFN);

Setup

Load the file angular-decorate.js directly after angular.js:

<script src="angular.js"></script>
<script src="angular-decorate.js"></script>

Example

Overwrite AngularJS' templateCache.get() function to always append .html.

angular.module('app').decorate('$templateCache', function ($delegate) {
    var _get = $delegate.get;
    $delegate.get = function (key) {
        return _get.call(_get, key + ".html");
    };
    return $delegate;
});

Related

Inspired by Brian Fords article Hacking Core Directives in AngularJS.

About

Use AngularJS' decorate function with ease

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published