| 
									
										
										
										
											2015-10-31 13:04:26 -07:00
										 |  |  | import {CONST, Type, stringify, isPresent, isString} from 'angular2/src/core/facade/lang'; | 
					
						
							| 
									
										
										
										
											2015-09-21 14:19:03 -07:00
										 |  |  | import {resolveForwardRef} from 'angular2/src/core/di'; | 
					
						
							|  |  |  | import {DependencyMetadata} from 'angular2/src/core/di/metadata'; | 
					
						
							| 
									
										
										
										
											2015-01-16 15:30:22 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-03-25 09:42:19 +01:00
										 |  |  | /** | 
					
						
							| 
									
										
										
										
											2015-04-14 23:26:49 +00:00
										 |  |  |  * Specifies that a constant attribute value should be injected. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * The directive can inject constant string literals of host element attributes. | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2015-10-19 15:37:32 +01:00
										 |  |  |  * ### Example | 
					
						
							| 
									
										
										
										
											2015-04-14 23:26:49 +00:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2015-04-15 22:35:38 +00:00
										 |  |  |  * Suppose we have an `<input>` element and want to know its `type`. | 
					
						
							| 
									
										
										
										
											2015-04-14 23:26:49 +00:00
										 |  |  |  * | 
					
						
							|  |  |  |  * ```html
 | 
					
						
							|  |  |  |  * <input type="text"> | 
					
						
							|  |  |  |  * ```
 | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2015-04-15 22:35:38 +00:00
										 |  |  |  * A decorator can inject string literal `text` like so: | 
					
						
							| 
									
										
										
										
											2015-04-14 23:26:49 +00:00
										 |  |  |  * | 
					
						
							|  |  |  |  * ```javascript
 | 
					
						
							| 
									
										
										
										
											2015-04-30 13:38:40 -07:00
										 |  |  |  * @Directive({ | 
					
						
							| 
									
										
										
										
											2015-04-14 23:26:49 +00:00
										 |  |  |  *   selector: `input'
 | 
					
						
							|  |  |  |  * }) | 
					
						
							| 
									
										
										
										
											2015-04-30 13:38:40 -07:00
										 |  |  |  * class InputDirective { | 
					
						
							| 
									
										
										
										
											2015-04-14 23:26:49 +00:00
										 |  |  |  *   constructor(@Attribute('type') type) { | 
					
						
							|  |  |  |  *     // type would be `text` in this example
 | 
					
						
							|  |  |  |  *   } | 
					
						
							|  |  |  |  * } | 
					
						
							|  |  |  |  * ```
 | 
					
						
							| 
									
										
										
										
											2015-03-25 09:42:19 +01:00
										 |  |  |  */ | 
					
						
							| 
									
										
										
										
											2015-05-20 09:48:15 -07:00
										 |  |  | @CONST() | 
					
						
							| 
									
										
										
										
											2015-08-14 10:03:45 -07:00
										 |  |  | export class AttributeMetadata extends DependencyMetadata { | 
					
						
							| 
									
										
										
										
											2015-05-20 09:48:15 -07:00
										 |  |  |   constructor(public attributeName: string) { super(); } | 
					
						
							| 
									
										
										
										
											2015-04-03 17:23:13 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |   get token() { | 
					
						
							| 
									
										
										
										
											2015-05-20 09:48:15 -07:00
										 |  |  |     // Normally one would default a token to a type of an injected value but here
 | 
					
						
							|  |  |  |     // the type of a variable is "string" and we can't use primitive type as a return value
 | 
					
						
							|  |  |  |     // so we use instance of Attribute instead. This doesn't matter much in practice as arguments
 | 
					
						
							|  |  |  |     // with @Attribute annotation are injected by ElementInjector that doesn't take tokens into
 | 
					
						
							|  |  |  |     // account.
 | 
					
						
							| 
									
										
										
										
											2015-04-03 17:23:13 +02:00
										 |  |  |     return this; | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2015-06-26 11:10:52 -07:00
										 |  |  |   toString(): string { return `@Attribute(${stringify(this.attributeName)})`; } | 
					
						
							| 
									
										
										
										
											2015-03-25 09:42:19 +01:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2015-03-13 11:39:15 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							| 
									
										
										
										
											2015-09-17 22:33:51 -07:00
										 |  |  |  * Declares an injectable parameter to be a live list of directives or variable | 
					
						
							|  |  |  |  * bindings from the content children of a directive. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * ### Example ([live demo](http://plnkr.co/edit/lY9m8HLy7z06vDoUaSN2?p=preview))
 | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Assume that `<tabs>` component would like to get a list its children `<pane>` | 
					
						
							|  |  |  |  * components as shown in this example: | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * ```html
 | 
					
						
							|  |  |  |  * <tabs> | 
					
						
							|  |  |  |  *   <pane title="Overview">...</pane> | 
					
						
							|  |  |  |  *   <pane *ng-for="#o of objects" [title]="o.title">{{o.text}}</pane> | 
					
						
							|  |  |  |  * </tabs> | 
					
						
							|  |  |  |  * ```
 | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * The preferred solution is to query for `Pane` directives using this decorator. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * ```javascript
 | 
					
						
							|  |  |  |  * @Component({ | 
					
						
							|  |  |  |  *   selector: 'pane', | 
					
						
							| 
									
										
										
										
											2015-09-30 20:59:23 -07:00
										 |  |  |  *   inputs: ['title'] | 
					
						
							| 
									
										
										
										
											2015-09-17 22:33:51 -07:00
										 |  |  |  * }) | 
					
						
							|  |  |  |  * class Pane { | 
					
						
							|  |  |  |  *   title:string; | 
					
						
							|  |  |  |  * } | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * @Component({ | 
					
						
							| 
									
										
										
										
											2015-10-11 07:41:19 -07:00
										 |  |  |  *  selector: 'tabs', | 
					
						
							| 
									
										
										
										
											2015-09-17 22:33:51 -07:00
										 |  |  |  *  template: `
 | 
					
						
							|  |  |  |  *    <ul> | 
					
						
							|  |  |  |  *      <li *ng-for="#pane of panes">{{pane.title}}</li> | 
					
						
							|  |  |  |  *    </ul> | 
					
						
							|  |  |  |  *    <content></content> | 
					
						
							|  |  |  |  *  `
 | 
					
						
							|  |  |  |  * }) | 
					
						
							|  |  |  |  * class Tabs { | 
					
						
							|  |  |  |  *   panes: QueryList<Pane>; | 
					
						
							|  |  |  |  *   constructor(@Query(Pane) panes:QueryList<Pane>) { | 
					
						
							|  |  |  |   *    this.panes = panes; | 
					
						
							|  |  |  |   *  } | 
					
						
							|  |  |  |  * } | 
					
						
							|  |  |  |  * ```
 | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2015-09-22 12:11:25 +03:00
										 |  |  |  * A query can look for variable bindings by passing in a string with desired binding symbol. | 
					
						
							| 
									
										
										
										
											2015-04-14 23:26:49 +00:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2015-09-17 22:33:51 -07:00
										 |  |  |  * ### Example ([live demo](http://plnkr.co/edit/sT2j25cH1dURAyBRCKx1?p=preview))
 | 
					
						
							|  |  |  |  * ```html
 | 
					
						
							|  |  |  |  * <seeker> | 
					
						
							|  |  |  |  *   <div #findme>...</div> | 
					
						
							|  |  |  |  * </seeker> | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2015-10-27 16:06:17 -07:00
										 |  |  |  * @Component({ selector: 'seeker' }) | 
					
						
							|  |  |  |  * class Seeker { | 
					
						
							| 
									
										
										
										
											2015-09-17 22:33:51 -07:00
										 |  |  |  *   constructor(@Query('findme') elList: QueryList<ElementRef>) {...} | 
					
						
							|  |  |  |  * } | 
					
						
							|  |  |  |  * ```
 | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * In this case the object that is injected depend on the type of the variable | 
					
						
							|  |  |  |  * binding. It can be an ElementRef, a directive or a component. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Passing in a comma separated list of variable bindings will query for all of them. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * ```html
 | 
					
						
							|  |  |  |  * <seeker> | 
					
						
							|  |  |  |  *   <div #find-me>...</div> | 
					
						
							|  |  |  |  *   <div #find-me-too>...</div> | 
					
						
							|  |  |  |  * </seeker> | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  *  @Component({ | 
					
						
							| 
									
										
										
										
											2015-10-27 16:06:17 -07:00
										 |  |  |  *   selector: 'seeker' | 
					
						
							| 
									
										
										
										
											2015-09-17 22:33:51 -07:00
										 |  |  |  * }) | 
					
						
							|  |  |  |  * class Seeker { | 
					
						
							|  |  |  |  *   constructor(@Query('findMe, findMeToo') elList: QueryList<ElementRef>) {...} | 
					
						
							|  |  |  |  * } | 
					
						
							|  |  |  |  * ```
 | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Configure whether query looks for direct children or all descendants | 
					
						
							|  |  |  |  * of the querying element, by using the `descendants` parameter. | 
					
						
							|  |  |  |  * It is set to `false` by default. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * ### Example ([live demo](http://plnkr.co/edit/wtGeB977bv7qvA5FTYl9?p=preview))
 | 
					
						
							|  |  |  |  * ```html
 | 
					
						
							|  |  |  |  * <container #first> | 
					
						
							|  |  |  |  *   <item>a</item> | 
					
						
							|  |  |  |  *   <item>b</item> | 
					
						
							|  |  |  |  *   <container #second> | 
					
						
							|  |  |  |  *     <item>c</item> | 
					
						
							|  |  |  |  *   </container> | 
					
						
							|  |  |  |  * </container> | 
					
						
							|  |  |  |  * ```
 | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * When querying for items, the first container will see only `a` and `b` by default, | 
					
						
							|  |  |  |  * but with `Query(TextDirective, {descendants: true})` it will see `c` too. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * The queried directives are kept in a depth-first pre-order with respect to their | 
					
						
							|  |  |  |  * positions in the DOM. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Query does not look deep into any subcomponent views. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Query is updated as part of the change-detection cycle. Since change detection | 
					
						
							|  |  |  |  * happens after construction of a directive, QueryList will always be empty when observed in the | 
					
						
							|  |  |  |  * constructor. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * The injected object is an unmodifiable live list. | 
					
						
							|  |  |  |  * See {@link QueryList} for more details. | 
					
						
							| 
									
										
										
										
											2015-03-13 11:39:15 -07:00
										 |  |  |  */ | 
					
						
							| 
									
										
										
										
											2015-05-20 09:48:15 -07:00
										 |  |  | @CONST() | 
					
						
							| 
									
										
										
										
											2015-08-14 10:03:45 -07:00
										 |  |  | export class QueryMetadata extends DependencyMetadata { | 
					
						
							| 
									
										
										
										
											2015-09-17 22:33:51 -07:00
										 |  |  |   /** | 
					
						
							|  |  |  |    * whether we want to query only direct children (false) or all | 
					
						
							|  |  |  |    * children (true). | 
					
						
							|  |  |  |    */ | 
					
						
							| 
									
										
										
										
											2015-06-10 17:08:22 -07:00
										 |  |  |   descendants: boolean; | 
					
						
							| 
									
										
										
										
											2015-09-19 18:39:35 -07:00
										 |  |  |   first: boolean; | 
					
						
							| 
									
										
										
										
											2015-09-17 22:33:51 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-15 15:18:11 -07:00
										 |  |  |   constructor(private _selector: Type | string, | 
					
						
							| 
									
										
										
										
											2015-09-19 18:39:35 -07:00
										 |  |  |               {descendants = false, first = false}: {descendants?: boolean, first?: boolean} = {}) { | 
					
						
							| 
									
										
										
										
											2015-06-10 17:08:22 -07:00
										 |  |  |     super(); | 
					
						
							|  |  |  |     this.descendants = descendants; | 
					
						
							| 
									
										
										
										
											2015-09-19 18:39:35 -07:00
										 |  |  |     this.first = first; | 
					
						
							| 
									
										
										
										
											2015-06-10 17:08:22 -07:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-09-17 22:33:51 -07:00
										 |  |  |   /** | 
					
						
							|  |  |  |    * always `false` to differentiate it with {@link ViewQueryMetadata}. | 
					
						
							|  |  |  |    */ | 
					
						
							|  |  |  |   get isViewQuery(): boolean { return false; } | 
					
						
							| 
									
										
										
										
											2015-07-10 10:30:31 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-09-17 22:33:51 -07:00
										 |  |  |   /** | 
					
						
							|  |  |  |    * what this is querying for. | 
					
						
							|  |  |  |    */ | 
					
						
							| 
									
										
										
										
											2015-06-15 13:24:43 -07:00
										 |  |  |   get selector() { return resolveForwardRef(this._selector); } | 
					
						
							| 
									
										
										
										
											2015-06-10 17:08:22 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-09-17 22:33:51 -07:00
										 |  |  |   /** | 
					
						
							|  |  |  |    * whether this is querying for a variable binding or a directive. | 
					
						
							|  |  |  |    */ | 
					
						
							| 
									
										
										
										
											2015-06-15 15:18:11 -07:00
										 |  |  |   get isVarBindingQuery(): boolean { return isString(this.selector); } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-09-17 22:33:51 -07:00
										 |  |  |   /** | 
					
						
							|  |  |  |    * returns a list of variable bindings this is querying for. | 
					
						
							|  |  |  |    * Only applicable if this is a variable bindings query. | 
					
						
							|  |  |  |    */ | 
					
						
							| 
									
										
										
										
											2015-10-31 13:04:26 -07:00
										 |  |  |   get varBindings(): string[] { return this.selector.split(','); } | 
					
						
							| 
									
										
										
										
											2015-06-15 15:18:11 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-26 11:10:52 -07:00
										 |  |  |   toString(): string { return `@Query(${stringify(this.selector)})`; } | 
					
						
							| 
									
										
										
										
											2015-03-13 11:39:15 -07:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2015-07-10 10:30:31 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-09-17 18:45:14 -07:00
										 |  |  | // TODO: add an example after ContentChildren and ViewChildren are in master
 | 
					
						
							|  |  |  | /** | 
					
						
							|  |  |  |  * Configures a content query. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Content queries are set before the `afterContentInit` callback is called. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * ### Example | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * ```
 | 
					
						
							|  |  |  |  * @Directive({ | 
					
						
							|  |  |  |  *   selector: 'someDir' | 
					
						
							|  |  |  |  * }) | 
					
						
							|  |  |  |  * class SomeDir { | 
					
						
							|  |  |  |  *   @ContentChildren(ChildDirective) contentChildren: QueryList<ChildDirective>; | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  *   afterContentInit() { | 
					
						
							|  |  |  |  *     // contentChildren is set
 | 
					
						
							|  |  |  |  *   } | 
					
						
							|  |  |  |  * } | 
					
						
							|  |  |  |  * ```
 | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | @CONST() | 
					
						
							|  |  |  | export class ContentChildrenMetadata extends QueryMetadata { | 
					
						
							|  |  |  |   constructor(_selector: Type | string, {descendants = false}: {descendants?: boolean} = {}) { | 
					
						
							|  |  |  |     super(_selector, {descendants: descendants}); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-09-19 18:39:35 -07:00
										 |  |  | // TODO: add an example after ContentChild and ViewChild are in master
 | 
					
						
							|  |  |  | /** | 
					
						
							|  |  |  |  * Configures a content query. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Content queries are set before the `afterContentInit` callback is called. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * ### Example | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * ```
 | 
					
						
							|  |  |  |  * @Directive({ | 
					
						
							|  |  |  |  *   selector: 'someDir' | 
					
						
							|  |  |  |  * }) | 
					
						
							|  |  |  |  * class SomeDir { | 
					
						
							|  |  |  |  *   @ContentChild(ChildDirective) contentChild; | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  *   afterContentInit() { | 
					
						
							|  |  |  |  *     // contentChild is set
 | 
					
						
							|  |  |  |  *   } | 
					
						
							|  |  |  |  * } | 
					
						
							|  |  |  |  * ```
 | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | @CONST() | 
					
						
							|  |  |  | export class ContentChildMetadata extends QueryMetadata { | 
					
						
							|  |  |  |   constructor(_selector: Type | string) { super(_selector, {descendants: true, first: true}); } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-10 10:30:31 -07:00
										 |  |  | /** | 
					
						
							| 
									
										
										
										
											2015-09-17 22:33:51 -07:00
										 |  |  |  * Similar to {@link QueryMetadata}, but querying the component view, instead of | 
					
						
							|  |  |  |  * the content children. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * ### Example ([live demo](http://plnkr.co/edit/eNsFHDf7YjyM6IzKxM1j?p=preview))
 | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * ```javascript
 | 
					
						
							|  |  |  |  * @Component({...}) | 
					
						
							|  |  |  |  * @View({ | 
					
						
							|  |  |  |  *   template: `
 | 
					
						
							|  |  |  |  *     <item> a </item> | 
					
						
							|  |  |  |  *     <item> b </item> | 
					
						
							|  |  |  |  *     <item> c </item> | 
					
						
							|  |  |  |  *   `
 | 
					
						
							|  |  |  |  * }) | 
					
						
							|  |  |  |  * class MyComponent { | 
					
						
							|  |  |  |  *   shown: boolean; | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  *   constructor(private @Query(Item) items:QueryList<Item>) { | 
					
						
							|  |  |  |  *     items.onChange(() => console.log(items.length)); | 
					
						
							|  |  |  |  *   } | 
					
						
							|  |  |  |  * } | 
					
						
							|  |  |  |  * ```
 | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Supports the same querying parameters as {@link QueryMetadata}, except | 
					
						
							|  |  |  |  * `descendants`. This always queries the whole view. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * As `shown` is flipped between true and false, items will contain zero of one | 
					
						
							|  |  |  |  * items. | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2015-07-10 10:30:31 -07:00
										 |  |  |  * Specifies that a {@link QueryList} should be injected. | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2015-09-17 22:33:51 -07:00
										 |  |  |  * The injected object is an iterable and observable live list. | 
					
						
							|  |  |  |  * See {@link QueryList} for more details. | 
					
						
							| 
									
										
										
										
											2015-07-10 10:30:31 -07:00
										 |  |  |  */ | 
					
						
							|  |  |  | @CONST() | 
					
						
							| 
									
										
										
										
											2015-08-14 10:03:45 -07:00
										 |  |  | export class ViewQueryMetadata extends QueryMetadata { | 
					
						
							| 
									
										
										
										
											2015-09-19 18:39:35 -07:00
										 |  |  |   constructor(_selector: Type | string, | 
					
						
							|  |  |  |               {descendants = false, first = false}: {descendants?: boolean, first?: boolean} = {}) { | 
					
						
							|  |  |  |     super(_selector, {descendants: descendants, first: first}); | 
					
						
							| 
									
										
										
										
											2015-07-10 10:30:31 -07:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-09-17 22:33:51 -07:00
										 |  |  |   /** | 
					
						
							|  |  |  |    * always `true` to differentiate it with {@link QueryMetadata}. | 
					
						
							|  |  |  |    */ | 
					
						
							| 
									
										
										
										
											2015-07-10 10:30:31 -07:00
										 |  |  |   get isViewQuery() { return true; } | 
					
						
							|  |  |  |   toString(): string { return `@ViewQuery(${stringify(this.selector)})`; } | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2015-09-17 18:45:14 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							|  |  |  |  * Configures a view query. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * View queries are set before the `afterViewInit` callback is called. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * ### Example | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * ```
 | 
					
						
							|  |  |  |  * @Component({ | 
					
						
							| 
									
										
										
										
											2015-10-11 07:41:19 -07:00
										 |  |  |  *   selector: 'someDir', | 
					
						
							|  |  |  |  *   templateUrl: 'someTemplate', | 
					
						
							|  |  |  |  *   directives: [ItemDirective] | 
					
						
							| 
									
										
										
										
											2015-09-17 18:45:14 -07:00
										 |  |  |  * }) | 
					
						
							|  |  |  |  * class SomeDir { | 
					
						
							|  |  |  |  *   @ViewChildren(ItemDirective) viewChildren: QueryList<ItemDirective>; | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  *   afterViewInit() { | 
					
						
							|  |  |  |  *     // viewChildren is set
 | 
					
						
							|  |  |  |  *   } | 
					
						
							|  |  |  |  * } | 
					
						
							|  |  |  |  * ```
 | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | @CONST() | 
					
						
							|  |  |  | export class ViewChildrenMetadata extends ViewQueryMetadata { | 
					
						
							|  |  |  |   constructor(_selector: Type | string) { super(_selector, {descendants: true}); } | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2015-09-19 18:39:35 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							|  |  |  |  * Configures a view query. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * View queries are set before the `afterViewInit` callback is called. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * ### Example | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * ```
 | 
					
						
							|  |  |  |  * @Component({ | 
					
						
							| 
									
										
										
										
											2015-10-11 07:41:19 -07:00
										 |  |  |  *   selector: 'someDir', | 
					
						
							|  |  |  |  *   templateUrl: 'someTemplate', | 
					
						
							|  |  |  |  *   directives: [ItemDirective] | 
					
						
							| 
									
										
										
										
											2015-09-19 18:39:35 -07:00
										 |  |  |  * }) | 
					
						
							|  |  |  |  * class SomeDir { | 
					
						
							|  |  |  |  *   @ViewChild(ItemDirective) viewChild:ItemDirective; | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  *   afterViewInit() { | 
					
						
							|  |  |  |  *     // viewChild is set
 | 
					
						
							|  |  |  |  *   } | 
					
						
							|  |  |  |  * } | 
					
						
							|  |  |  |  * ```
 | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | @CONST() | 
					
						
							|  |  |  | export class ViewChildMetadata extends ViewQueryMetadata { | 
					
						
							|  |  |  |   constructor(_selector: Type | string) { super(_selector, {descendants: true, first: true}); } | 
					
						
							| 
									
										
										
										
											2015-10-11 07:41:19 -07:00
										 |  |  | } |