From 3e6f6339a537c569cb99bc54746d189545345485 Mon Sep 17 00:00:00 2001 From: "Dmitry V. Abuzyarov" Date: Sun, 31 May 2015 13:48:30 +0300 Subject: [PATCH] Add Decorator definition to IModule --- angularjs/angular-tests.ts | 3 +++ angularjs/angular.d.ts | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/angularjs/angular-tests.ts b/angularjs/angular-tests.ts index 628b6d1d2..7511f3627 100644 --- a/angularjs/angular-tests.ts +++ b/angularjs/angular-tests.ts @@ -201,6 +201,9 @@ mod.constant(My.Namespace); mod.value('name', 23); mod.value('name', "23"); mod.value(My.Namespace); +mod.decorator('name', function($scope:ng.IScope){ }); +mod.decorator('name', ['$scope', function($scope: ng.IScope){ }]); + class TestProvider implements ng.IServiceProvider { constructor(private $scope: ng.IScope) { diff --git a/angularjs/angular.d.ts b/angularjs/angular.d.ts index 457a1df35..621f0b3e5 100755 --- a/angularjs/angular.d.ts +++ b/angularjs/angular.d.ts @@ -384,6 +384,14 @@ declare module angular { value(name: string, value: any): IModule; value(object: Object): IModule; + /** + * Register a service decorator with the $injector. A service decorator intercepts the creation of a service, allowing it to override or modify the behaviour 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. + * @param name The name of the service to decorate + * @param decorator 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. + */ + decorator(name:string, decoratorConstructor: Function): IModule; + decorator(name:string, inlineAnnotatedConstructor: any[]): IModule; + // Properties name: string; requires: string[];