Skip to content

Commit f995b07

Browse files
committed
docs: annotations edits
1 parent 101a4aa commit f995b07

File tree

2 files changed

+34
-23
lines changed

2 files changed

+34
-23
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ export class Directive extends Injectable {
326326
*
327327
*
328328
*
329-
* ## Bindings With Pipes:
329+
* ## Bindings With Pipes
330330
*
331331
* You can also use pipes when writing binding definitions for a directive.
332332
*

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

Lines changed: 33 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,11 @@ import {CONST} from 'angular2/src/facade/lang';
22
import {DependencyAnnotation} from 'angular2/di';
33

44
/**
5-
* The directive can only be injected from the parent element.
5+
* Specifies that an injector should retrieve a dependency from the direct parent.
66
*
77
* ## Example
88
*
9-
* ```
10-
* <div dependency="1">
11-
* <div dependency="2" my-directive></div>
12-
* </div>
13-
* ```
9+
* Here is a simple directive that retrieves a dependency from its parent element.
1410
*
1511
* ```
1612
* @Decorator({
@@ -34,8 +30,15 @@ import {DependencyAnnotation} from 'angular2/di';
3430
* }
3531
* ```
3632
*
37-
* In the above example the `@Parent()` annotation forces the injector to retrieve the dependency from the
38-
* parent element (even thought the current element could resolve it).
33+
* We use this with the following HTML template:
34+
*
35+
* ```
36+
* <div dependency="1">
37+
* <div dependency="2" my-directive></div>
38+
* </div>
39+
* ```
40+
* The `@Parent()` annotation in our constructor forces the injector to retrieve the dependency from the
41+
* parent element (even thought the current element could resolve it): Angular injects `dependency=1`.
3942
*
4043
* @publicModule angular2/annotations
4144
*/
@@ -47,20 +50,14 @@ export class Parent extends DependencyAnnotation {
4750
}
4851

4952
/**
50-
* The directive can only be injected from the ancestor (any element between parent element and shadow root).
53+
* Specifies that an injector should retrieve a dependency from any ancestor element.
54+
*
55+
* An ancestor is any element between the parent element and shadow root.
5156
*
5257
*
5358
* ## Example
5459
*
55-
* ```
56-
* <div dependency="1">
57-
* <div dependency="2">
58-
* <div>
59-
* <div dependency="3" my-directive></div>
60-
* </div>
61-
* </div>
62-
* </div>
63-
* ```
60+
* Here is a simple directive that retrieves a dependency from an ancestor element.
6461
*
6562
* ```
6663
* @Decorator({
@@ -83,12 +80,26 @@ export class Parent extends DependencyAnnotation {
8380
* };
8481
* }
8582
* ```
83+
*
84+
* We use this with the following HTML template:
85+
*
86+
* ```
87+
* <div dependency="1">
88+
* <div dependency="2">
89+
* <div>
90+
* <div dependency="3" my-directive></div>
91+
* </div>
92+
* </div>
93+
* </div>
94+
* ```
8695
*
87-
* In the above example the `@Ancestor()` annotation forces the injector to retrieve the dependency from the
88-
* first ancestor.
89-
* - The current element `dependency="3"` is skipped
96+
* The `@Ancestor()` annotation in our constructor forces the injector to retrieve the dependency from the
97+
* nearest ancestor element:
98+
* - The current element `dependency="3"` is skipped because it is not an ancestor.
9099
* - Next parent has no directives `<div>`
91-
* - Next parent has the `Dependency` directive and so the dependency is satisfied.
100+
* - Next parent has the `Dependency` directive and so the dependency is satisfied.
101+
*
102+
* Angular injects `dependency=2`.
92103
*
93104
* @publicModule angular2/annotations
94105
*/

0 commit comments

Comments
 (0)