From b656f63430ab881fe87eedef7f7dcf19c9cacd9e Mon Sep 17 00:00:00 2001 From: Tim Blasi Date: Mon, 16 Mar 2015 14:43:22 -0700 Subject: [PATCH] feat(di): Add the `@Injectable` annotation Add an annotation marking a class as available to `Injector`s. --- modules/angular2/di.js | 2 +- modules/angular2/src/di/annotations.js | 21 ++++++++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/modules/angular2/di.js b/modules/angular2/di.js index f98c12fc4b..f54eb8cace 100644 --- a/modules/angular2/di.js +++ b/modules/angular2/di.js @@ -1,4 +1,4 @@ -export {Inject, InjectPromise, InjectLazy, Optional, DependencyAnnotation} from './src/di/annotations'; +export {Inject, InjectPromise, InjectLazy, Injectable, Optional, DependencyAnnotation} from './src/di/annotations'; export {Injector} from './src/di/injector'; export {Binding, Dependency, bind} from './src/di/binding'; export {Key, KeyRegistry} from './src/di/key'; diff --git a/modules/angular2/src/di/annotations.js b/modules/angular2/src/di/annotations.js index 425b3991bb..d2197918bd 100644 --- a/modules/angular2/src/di/annotations.js +++ b/modules/angular2/src/di/annotations.js @@ -107,4 +107,23 @@ export class DependencyAnnotation { @CONST() constructor() { } -} \ No newline at end of file +} + +/** + * A class annotation that marks a class as available to `Injector`s for + * creation. + * + * ``` + * class NeedsService { + * constructor(svc:UsefulService) {} + * } + * + * @Injectable + * class UsefulService {} + * ``` + */ +export class Injectable { + @CONST() + constructor() { + } +}