Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 083d6f1

Browse files
RodneyEbanksnetman92
authored andcommittedAug 8, 2015
feat(angular.Module): add decorator method
Closes angular#11305 Closes angular#11300
1 parent 890c425 commit 083d6f1

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed
 

‎src/loader.js

+12
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,18 @@ function setupModuleLoader(window) {
193193
*/
194194
constant: invokeLater('$provide', 'constant', 'unshift'),
195195

196+
/**
197+
* @ngdoc method
198+
* @name angular.Module#decorator
199+
* @module ng
200+
* @param {string} The name of the service to decorate.
201+
* @param {Function} This function will be invoked when the service needs to be
202+
* instantiated and should return the decorated service instance.
203+
* @description
204+
* See {@link auto.$provide#decorator $provide.decorator()}.
205+
*/
206+
decorator: invokeLater('$provide', 'decorator'),
207+
196208
/**
197209
* @ngdoc method
198210
* @name angular.Module#animation

‎test/loaderSpec.js

+2
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ describe('module loader', function() {
3232
var myModule = window.angular.module('my', ['other'], 'config');
3333

3434
expect(myModule.
35+
decorator('dk', 'dv').
3536
provider('sk', 'sv').
3637
factory('fk', 'fv').
3738
service('a', 'aa').
@@ -46,6 +47,7 @@ describe('module loader', function() {
4647
expect(myModule.requires).toEqual(['other']);
4748
expect(myModule._invokeQueue).toEqual([
4849
['$provide', 'constant', ['abc', 123]],
50+
['$provide', 'decorator', ['dk', 'dv']],
4951
['$provide', 'provider', ['sk', 'sv']],
5052
['$provide', 'factory', ['fk', 'fv']],
5153
['$provide', 'service', ['a', 'aa']],

0 commit comments

Comments
 (0)
Please sign in to comment.