From 50d34ac8db29c4db3297ae59198d311999c89420 Mon Sep 17 00:00:00 2001 From: Albert Weinert Date: Wed, 3 Apr 2013 14:44:24 +0300 Subject: [PATCH 1/2] angular.d.ts: added some overrides to ng.IModule with angular it is possible to register controllers, directives etc. per convention if you create an object which has the functions defined. So that your module initialization must not know every controller etc. As an example look at https://github.com/DerAlbertCom/SignagePages/blob/develop/src/SignagePages/app/app.ts https://github.com/DerAlbertCom/SignagePages/blob/develop/src/SignagePages/app/LoginController.js https://github.com/DerAlbertCom/SignagePages/blob/develop/src/SignagePages/app/DailyMealsController.ts --- angularjs/angular.d.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/angularjs/angular.d.ts b/angularjs/angular.d.ts index b8d683c5c1..51fe920654 100644 --- a/angularjs/angular.d.ts +++ b/angularjs/angular.d.ts @@ -83,18 +83,24 @@ module ng { constant(name: string, value: any): IModule; controller(name: string, controllerConstructor: Function): IModule; controller(name: string, inlineAnnotadedConstructor: any[]): IModule; + controller(object : {}): IModule; directive(name: string, directiveFactory: Function): IModule; directive(name: string, inlineAnnotadedFunction: any[]): IModule; + directive(object: {}): IModule; factory(name: string, serviceFactoryFunction: Function): IModule; factory(name: string, inlineAnnotadedFunction: any[]): IModule; + factory(obj: {}): IModule; filter(name: string, filterFactoryFunction: Function): IModule; filter(name: string, inlineAnnotadedFunction: any[]): IModule; + filter(object: {}): IModule; provider(name: string, serviceProviderConstructor: Function): IModule; provider(name: string, inlineAnnotadedConstructor: any[]): IModule; + provider(object: {}): IModule; run(initializationFunction: Function): IModule; run(inlineAnnotadedFunction: any[]): IModule; service(name: string, serviceConstructor: Function): IModule; service(name: string, inlineAnnotadedConstructor: any[]): IModule; + service(object: {}): IModule; value(name: string, value: any): IModule; // Properties From 558d616fd5f30d9fefa9eef6b7bcbb606224de4e Mon Sep 17 00:00:00 2001 From: Albert Weinert Date: Wed, 3 Apr 2013 16:05:10 +0200 Subject: [PATCH 2/2] angular.d.t.s ng.IModule use of Object instead of {}, added tests --- angularjs/angular-tests.ts | 33 +++++++++++++++++++++++++++++++++ angularjs/angular.d.ts | 14 ++++++++------ 2 files changed, 41 insertions(+), 6 deletions(-) diff --git a/angularjs/angular-tests.ts b/angularjs/angular-tests.ts index d5414dc627..6354e188cb 100644 --- a/angularjs/angular-tests.ts +++ b/angularjs/angular-tests.ts @@ -138,3 +138,36 @@ module HttpAndRegularPromiseTests { }); } } + +// Test for AngularJS Syntac + +module My.Namespace { + +} + +// IModule Registering Test +var mod = angular.module('tests',[]); +mod.controller('name', function($scope : ng.IScope) {}) +mod.controller('name', ['$scope', function($scope : ng.IScope) {}]) +mod.controller(My.Namespace); +mod.directive('name', function($scope : ng.IScope) {}) +mod.directive('name', ['$scope', function($scope : ng.IScope) {}]) +mod.directive(My.Namespace); +mod.factory('name', function($scope : ng.IScope) {}) +mod.factory('name', ['$scope', function($scope : ng.IScope) {}]) +mod.factory(My.Namespace); +mod.filter('name', function($scope : ng.IScope) {}) +mod.filter('name', ['$scope', function($scope : ng.IScope) {}]) +mod.filter(My.Namespace); +mod.provider('name', function($scope : ng.IScope) {}) +mod.provider('name', ['$scope', function($scope : ng.IScope) {}]) +mod.provider(My.Namespace); +mod.service('name', function($scope : ng.IScope) {}) +mod.service('name', ['$scope', function($scope : ng.IScope) {}]) +mod.service(My.Namespace); +mod.constant('name', 23); +mod.constant('name', "23"); +mod.constant(My.Namespace); +mod.value('name', 23); +mod.value('name', "23"); +mod.value(My.Namespace); diff --git a/angularjs/angular.d.ts b/angularjs/angular.d.ts index 51fe920654..a5e151c81f 100644 --- a/angularjs/angular.d.ts +++ b/angularjs/angular.d.ts @@ -81,27 +81,29 @@ module ng { */ config(inlineAnnotadedFunction: any[]): IModule; constant(name: string, value: any): IModule; + constant(object: Object): IModule; controller(name: string, controllerConstructor: Function): IModule; controller(name: string, inlineAnnotadedConstructor: any[]): IModule; - controller(object : {}): IModule; + controller(object : Object): IModule; directive(name: string, directiveFactory: Function): IModule; directive(name: string, inlineAnnotadedFunction: any[]): IModule; - directive(object: {}): IModule; + directive(object: Object): IModule; factory(name: string, serviceFactoryFunction: Function): IModule; factory(name: string, inlineAnnotadedFunction: any[]): IModule; - factory(obj: {}): IModule; + factory(object: Object): IModule; filter(name: string, filterFactoryFunction: Function): IModule; filter(name: string, inlineAnnotadedFunction: any[]): IModule; - filter(object: {}): IModule; + filter(object: Object): IModule; provider(name: string, serviceProviderConstructor: Function): IModule; provider(name: string, inlineAnnotadedConstructor: any[]): IModule; - provider(object: {}): IModule; + provider(object: Object): IModule; run(initializationFunction: Function): IModule; run(inlineAnnotadedFunction: any[]): IModule; service(name: string, serviceConstructor: Function): IModule; service(name: string, inlineAnnotadedConstructor: any[]): IModule; - service(object: {}): IModule; + service(object: Object): IModule; value(name: string, value: any): IModule; + value(object: Object): IModule; // Properties name: string;