docs: annotations edits
This commit is contained in:
parent
101a4aa3cf
commit
f995b07876
@ -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.
|
* You can also use pipes when writing binding definitions for a directive.
|
||||||
*
|
*
|
||||||
|
@ -2,15 +2,11 @@ import {CONST} from 'angular2/src/facade/lang';
|
|||||||
import {DependencyAnnotation} from 'angular2/di';
|
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
|
* ## Example
|
||||||
*
|
*
|
||||||
* ```
|
* Here is a simple directive that retrieves a dependency from its parent element.
|
||||||
* <div dependency="1">
|
|
||||||
* <div dependency="2" my-directive></div>
|
|
||||||
* </div>
|
|
||||||
* ```
|
|
||||||
*
|
*
|
||||||
* ```
|
* ```
|
||||||
* @Decorator({
|
* @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
|
* We use this with the following HTML template:
|
||||||
* parent element (even thought the current element could resolve it).
|
*
|
||||||
|
* ```
|
||||||
|
* <div dependency="1">
|
||||||
|
* <div dependency="2" my-directive></div>
|
||||||
|
* </div>
|
||||||
|
* ```
|
||||||
|
* 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
|
* @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
|
* ## Example
|
||||||
*
|
*
|
||||||
* ```
|
* Here is a simple directive that retrieves a dependency from an ancestor element.
|
||||||
* <div dependency="1">
|
|
||||||
* <div dependency="2">
|
|
||||||
* <div>
|
|
||||||
* <div dependency="3" my-directive></div>
|
|
||||||
* </div>
|
|
||||||
* </div>
|
|
||||||
* </div>
|
|
||||||
* ```
|
|
||||||
*
|
*
|
||||||
* ```
|
* ```
|
||||||
* @Decorator({
|
* @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.
|
* <div dependency="1">
|
||||||
* - The current element `dependency="3"` is skipped
|
* <div dependency="2">
|
||||||
|
* <div>
|
||||||
|
* <div dependency="3" my-directive></div>
|
||||||
|
* </div>
|
||||||
|
* </div>
|
||||||
|
* </div>
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* 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 `<div>`
|
* - Next parent has no directives `<div>`
|
||||||
* - 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
|
* @publicModule angular2/annotations
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user