Skip to content

Commit 87ac100

Browse files
committed
docs: add DI to public docs
1 parent 487c4d2 commit 87ac100

File tree

17 files changed

+581
-105
lines changed

17 files changed

+581
-105
lines changed

gulpfile.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,7 @@ function createDocsTasks(public) {
402402
var dgeni = new Dgeni([require(dgeniPackage)]);
403403
return dgeni.generate();
404404
} catch(x) {
405+
console.log(x);
405406
console.log(x.stack);
406407
throw x;
407408
}

modules/angular2/core.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @module
33
* @public
44
* @description
5-
* Define public API for Angular here.
5+
* Define angular core API here.
66
*/
77
export * from './src/core/annotations/visibility';
88
export * from './src/core/compiler/interfaces';

modules/angular2/di.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/**
22
* @module
3+
* @public
34
* @description
45
* This is a description
56
*/

modules/angular2/di_annotations.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/**
2+
* @module
3+
* @public
4+
* @description
5+
* This is a description
6+
*/
7+

modules/angular2/di_errors.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/**
2+
* @module
3+
* @public
4+
* @description
5+
* This is a description
6+
*/
7+

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ export class PropertySetter extends DependencyAnnotation {
3030
*
3131
* ## Example
3232
*
33-
* suppose we have an `<input>` element and would like to know its `type`.
33+
* Suppose we have an `<input>` element and want to know its `type`.
3434
*
3535
* ```html
3636
* <input type="text">
3737
* ```
3838
*
39-
* A decorator could inject string literal `text` like so:
39+
* A decorator can inject string literal `text` like so:
4040
*
4141
* ```javascript
4242
* @Decorator({
@@ -71,7 +71,7 @@ export class Attribute extends DependencyAnnotation {
7171
/**
7272
* Specifies that a [QueryList] should be injected.
7373
*
74-
* See: [QueryList] for usage.
74+
* See: [QueryList] for usage and example.
7575
*
7676
* @exportedAs angular2/annotations
7777
*/

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

Lines changed: 37 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -33,38 +33,57 @@ import {ABSTRACT, CONST, Type} from 'angular2/src/facade/lang';
3333
* @exportedAs angular2/annotations
3434
*/
3535
export class View {
36+
/**
37+
* Specify a template URL for an angular component.
38+
*
39+
* NOTE: either `templateURL` or `template` should be used, but not both.
40+
*/
3641
templateUrl:any; //string;
42+
43+
/**
44+
* Specify an inline template for an angular component.
45+
*
46+
* NOTE: either `templateURL` or `template` should be used, but not both.
47+
*/
3748
template:any; //string;
49+
50+
/**
51+
* Specify a list of directives that are active within a template. [TODO: true?]
52+
*
53+
* Directives must be listed explicitly to provide proper component encapsulation.
54+
*
55+
* ## Example
56+
*
57+
* ```javascript
58+
* @Component({
59+
* selector: 'my-component'
60+
* })
61+
* @View({
62+
* directives: [For]
63+
* template: '
64+
* <ul>
65+
* <li *for="item in items">{{item}}</li>
66+
* </ul>'
67+
* })
68+
* class MyComponent {
69+
* }
70+
* ```
71+
*/
3872
directives:any; //List<Type>;
39-
formatters:any; //List<Type>;
40-
source:any;//List<View>;
41-
locale:any; //string
42-
device:any; //string
73+
4374
@CONST()
4475
constructor({
4576
templateUrl,
4677
template,
47-
directives,
48-
formatters,
49-
source,
50-
locale,
51-
device
78+
directives
5279
}: {
5380
templateUrl: string,
5481
template: string,
55-
directives: List<Type>,
56-
formatters: List<Type>,
57-
source: List<View>,
58-
locale: string,
59-
device: string
82+
directives: List<Type>
6083
})
6184
{
6285
this.templateUrl = templateUrl;
6386
this.template = template;
6487
this.directives = directives;
65-
this.formatters = formatters;
66-
this.source = source;
67-
this.locale = locale;
68-
this.device = device;
6988
}
7089
}

modules/angular2/src/core/life_cycle/life_cycle.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ import {isPresent} from 'angular2/src/facade/lang';
2626
* lifecycle.tick();
2727
* });
2828
* ```
29-
*
30-
*
3129
* @exportedAs angular2/change_detection
3230
*/
3331
@Injectable()

modules/angular2/src/di/annotations.js

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@ import {CONST} from "angular2/src/facade/lang";
55
*
66
* ```
77
* class AComponent {
8-
* constructor(@Inject('aServiceToken') aService) {}
8+
* constructor(@Inject(MyService) aService:MyService) {}
99
* }
1010
* ```
1111
*
12+
* @exportedAs angular2/di_annotations
1213
*/
1314
export class Inject {
1415
token;
@@ -23,12 +24,13 @@ export class Inject {
2324
*
2425
* ```
2526
* class AComponent {
26-
* constructor(@InjectPromise('aServiceToken') aServicePromise) {
27-
* aServicePromise.then(aService => ...);
27+
* constructor(@InjectPromise(MyService) aServicePromise:Promise<MyService>) {
28+
* aServicePromise.then(aService:MyService => ...);
2829
* }
2930
* }
3031
* ```
3132
*
33+
* @exportedAs angular2/di_annotations
3234
*/
3335
export class InjectPromise {
3436
token;
@@ -43,12 +45,13 @@ export class InjectPromise {
4345
*
4446
* ```
4547
* class AComponent {
46-
* constructor(@InjectLazy('aServiceToken') aServiceFn) {
47-
* aService = aServiceFn();
48+
* constructor(@InjectLazy(MyService) aServiceFn:Function) {
49+
* var aService:MyService = aServiceFn();
4850
* }
4951
* }
5052
* ```
5153
*
54+
* @exportedAs angular2/di_annotations
5255
*/
5356
export class InjectLazy {
5457
token;
@@ -59,16 +62,16 @@ export class InjectLazy {
5962
}
6063

6164
/**
62-
* A parameter annotation that marks a dependency as optional.
63-
*
65+
* A parameter annotation that marks a dependency as optional. (Injects `null` if not found.)
6466
* ```
6567
* class AComponent {
66-
* constructor(@Optional() dp:Dependency) {
67-
* this.dp = dp;
68+
* constructor(@Optional() aService:MyService) {
69+
* this.aService = aService;
6870
* }
6971
* }
7072
* ```
7173
*
74+
* @exportedAs angular2/di_annotations
7275
*/
7376
export class Optional {
7477
@CONST()
@@ -102,6 +105,7 @@ export class Optional {
102105
* The framework can use `new Parent()` to handle the `aService` dependency
103106
* in a specific way.
104107
*
108+
* @exportedAs angular2/di_annotations
105109
*/
106110
export class DependencyAnnotation {
107111
@CONST()
@@ -114,8 +118,8 @@ export class DependencyAnnotation {
114118
}
115119

116120
/**
117-
* A class annotation that marks a class as available to `Injector`s for
118-
* creation.
121+
* A marker annotation that marks a class as available to `Injector`s for creation. Used by tooling for generating
122+
* constructor stubs.
119123
*
120124
* ```
121125
* class NeedsService {
@@ -125,6 +129,7 @@ export class DependencyAnnotation {
125129
* @Injectable
126130
* class UsefulService {}
127131
* ```
132+
* @exportedAs angular2/di_annotations
128133
*/
129134
export class Injectable {
130135
@CONST()

0 commit comments

Comments
 (0)