Skip to content

Commit 457c15c

Browse files
committed
feat(decorators): adds decorator versions of DI annotations.
In 'angular2/di' the symbol: - Inject is a decorator - InjectAnnotation is an annotation Internally one an get a hold of annotations without *Annotations appened (to make ts2dart work without workarounds) by importing from 'angular2/src/di/annotations_impl' instead of 'angular2/di'. This is needed only for users that transpile through TS and through ts2dart.
1 parent 28feac9 commit 457c15c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+121
-74
lines changed

modules/angular2/annotations.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@
99
*
1010
*/
1111
export * from './src/core/annotations/annotations';
12-
export * from './src/core/decorators/decorators';
12+
export * from './src/core/annotations/decorators';

modules/angular2/di.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
* The `di` module provides dependency injection container services.
66
*/
77

8-
export {Inject, InjectPromise, InjectLazy, Injectable, Optional, DependencyAnnotation} from './src/di/annotations';
8+
export * from './src/di/annotations';
9+
export * from './src/di/decorators';
910
export {Injector} from './src/di/injector';
1011
export {Binding, ResolvedBinding, Dependency, bind} from './src/di/binding';
1112
export {Key, KeyRegistry} from './src/di/key';

modules/angular2/src/change_detection/change_detection.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@ import {BindingRecord} from './binding_record';
88
import {DirectiveRecord} from './directive_record';
99
import {DEFAULT} from './constants';
1010
import {ChangeDetection, ProtoChangeDetector} from './interfaces';
11-
import {Injectable} from 'angular2/di';
11+
import {Injectable} from 'angular2/src/di/annotations_impl';
1212
import {List} from 'angular2/src/facade/collection';
1313

14-
1514
/**
1615
* Structural diffing for `Object`s and `Map`s.
1716
*

modules/angular2/src/change_detection/parser/lexer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Injectable} from 'angular2/di';
1+
import {Injectable} from 'angular2/src/di/annotations_impl';
22
import {List, ListWrapper, SetWrapper} from "angular2/src/facade/collection";
33
import {int, NumberWrapper, StringJoiner, StringWrapper} from "angular2/src/facade/lang";
44

modules/angular2/src/change_detection/parser/parser.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Injectable} from 'angular2/di';
1+
import {Injectable} from 'angular2/src/di/annotations_impl';
22
import {int, isBlank, isPresent, BaseException, StringWrapper, RegExpWrapper} from 'angular2/src/facade/lang';
33
import {ListWrapper, List} from 'angular2/src/facade/collection';
44
import {Lexer, EOF, Token, $PERIOD, $COLON, $SEMICOLON, $LBRACKET, $RBRACKET,

modules/angular2/src/change_detection/pipes/pipe_registry.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {List, ListWrapper} from 'angular2/src/facade/collection';
22
import {isBlank, isPresent, BaseException, CONST} from 'angular2/src/facade/lang';
33
import {Pipe} from './pipe';
4-
import {Injectable} from 'angular2/di';
4+
import {Injectable} from 'angular2/src/di/annotations_impl';
55
import {ChangeDetectorRef} from '../change_detector_ref';
66

77
@Injectable()
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import {
2+
ComponentAnnotation,
3+
DirectiveAnnotation
4+
} from './annotations';
5+
import {ViewAnnotation} from './view';
6+
import {AncestorAnnotation, ParentAnnotation} from './visibility';
7+
import {AttributeAnnotation, QueryAnnotation} from './di';
8+
import {makeDecorator, makeParamDecorator} from '../../util/decorators';
9+
10+
/* from annotations */
11+
export var Component = makeDecorator(ComponentAnnotation);
12+
export var Decorator = makeDecorator(DirectiveAnnotation);
13+
14+
/* from view */
15+
export var View = makeDecorator(ViewAnnotation);
16+
17+
/* from visibility */
18+
export var Ancestor = makeParamDecorator(AncestorAnnotation);
19+
export var Parent = makeParamDecorator(ParentAnnotation);
20+
21+
/* from di */
22+
export var Attribute = makeParamDecorator(AttributeAnnotation);
23+
export var Query = makeParamDecorator(QueryAnnotation);

modules/angular2/src/core/annotations_impl/annotations.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {CONST, normalizeBlank, isPresent} from 'angular2/src/facade/lang';
22
import {ListWrapper, List} from 'angular2/src/facade/collection';
3-
import {Injectable} from 'angular2/di';
3+
import {Injectable} from 'angular2/src/di/annotations_impl';
44
import {DEFAULT} from 'angular2/change_detection';
55

66
// type StringMap = {[idx: string]: string};

modules/angular2/src/core/annotations_impl/di.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {CONST} from 'angular2/src/facade/lang';
2-
import {DependencyAnnotation} from 'angular2/di';
2+
import {DependencyAnnotation} from 'angular2/src/di/annotations_impl';
33

44
/**
55
* Specifies that a constant attribute value should be injected.

0 commit comments

Comments
 (0)