From f995b07876bfa61245eba237cc36bf9890683bf6 Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Tue, 24 Mar 2015 23:27:07 +0000 Subject: [PATCH] docs: annotations edits --- .../src/core/annotations/annotations.js | 2 +- .../src/core/annotations/visibility.js | 55 +++++++++++-------- 2 files changed, 34 insertions(+), 23 deletions(-) diff --git a/modules/angular2/src/core/annotations/annotations.js b/modules/angular2/src/core/annotations/annotations.js index ac845cb265..94046b8e6c 100644 --- a/modules/angular2/src/core/annotations/annotations.js +++ b/modules/angular2/src/core/annotations/annotations.js @@ -326,7 +326,7 @@ export class Directive extends Injectable { * * * - * ## Bindings With Pipes: + * ## Bindings With Pipes * * You can also use pipes when writing binding definitions for a directive. * diff --git a/modules/angular2/src/core/annotations/visibility.js b/modules/angular2/src/core/annotations/visibility.js index 586710c0e6..06b0c73c6c 100644 --- a/modules/angular2/src/core/annotations/visibility.js +++ b/modules/angular2/src/core/annotations/visibility.js @@ -2,15 +2,11 @@ import {CONST} from 'angular2/src/facade/lang'; import {DependencyAnnotation} from 'angular2/di'; /** - * The directive can only be injected from the parent element. + * Specifies that an injector should retrieve a dependency from the direct parent. * * ## Example * - * ``` - *
- *
- *
- * ``` + * Here is a simple directive that retrieves a dependency from its parent element. * * ``` * @Decorator({ @@ -34,8 +30,15 @@ import {DependencyAnnotation} from 'angular2/di'; * } * ``` * - * In the above example the `@Parent()` annotation forces the injector to retrieve the dependency from the - * parent element (even thought the current element could resolve it). + * We use this with the following HTML template: + * + * ``` + *
+ *
+ *
+ * ``` + * The `@Parent()` annotation in our constructor forces the injector to retrieve the dependency from the + * parent element (even thought the current element could resolve it): Angular injects `dependency=1`. * * @publicModule angular2/annotations */ @@ -47,20 +50,14 @@ export class Parent extends DependencyAnnotation { } /** - * The directive can only be injected from the ancestor (any element between parent element and shadow root). + * Specifies that an injector should retrieve a dependency from any ancestor element. + * + * An ancestor is any element between the parent element and shadow root. * * * ## Example * - * ``` - *
- *
- *
- *
- *
- *
- *
- * ``` + * Here is a simple directive that retrieves a dependency from an ancestor element. * * ``` * @Decorator({ @@ -83,12 +80,26 @@ export class Parent extends DependencyAnnotation { * }; * } * ``` + * + * We use this with the following HTML template: * - * In the above example the `@Ancestor()` annotation forces the injector to retrieve the dependency from the - * first ancestor. - * - The current element `dependency="3"` is skipped + * ``` + *
+ *
+ *
+ *
+ *
+ *
+ *
+ * ``` + * + * The `@Ancestor()` annotation in our constructor forces the injector to retrieve the dependency from the + * nearest ancestor element: + * - The current element `dependency="3"` is skipped because it is not an ancestor. * - Next parent has no directives `
` - * - Next parent has the `Dependency` directive and so the dependency is satisfied. + * - Next parent has the `Dependency` directive and so the dependency is satisfied. + * + * Angular injects `dependency=2`. * * @publicModule angular2/annotations */