@@ -170,11 +170,13 @@ export class QueryMetadata extends DependencyMetadata {
170170 * children (true).
171171 */
172172 descendants : boolean ;
173+ first : boolean ;
173174
174175 constructor ( private _selector : Type | string ,
175- { descendants = false } : { descendants ?: boolean } = { } ) {
176+ { descendants = false , first = false } : { descendants ?: boolean , first ?: boolean } = { } ) {
176177 super ( ) ;
177178 this . descendants = descendants ;
179+ this . first = first ;
178180 }
179181
180182 /**
@@ -229,6 +231,32 @@ export class ContentChildrenMetadata extends QueryMetadata {
229231 }
230232}
231233
234+ // TODO: add an example after ContentChild and ViewChild are in master
235+ /**
236+ * Configures a content query.
237+ *
238+ * Content queries are set before the `afterContentInit` callback is called.
239+ *
240+ * ### Example
241+ *
242+ * ```
243+ * @Directive ({
244+ * selector: 'someDir'
245+ * })
246+ * class SomeDir {
247+ * @ContentChild (ChildDirective) contentChild;
248+ *
249+ * afterContentInit() {
250+ * // contentChild is set
251+ * }
252+ * }
253+ * ```
254+ */
255+ @CONST ( )
256+ export class ContentChildMetadata extends QueryMetadata {
257+ constructor ( _selector : Type | string ) { super ( _selector , { descendants : true , first : true } ) ; }
258+ }
259+
232260/**
233261 * Similar to {@link QueryMetadata}, but querying the component view, instead of
234262 * the content children.
@@ -266,8 +294,9 @@ export class ContentChildrenMetadata extends QueryMetadata {
266294 */
267295@CONST ( )
268296export class ViewQueryMetadata extends QueryMetadata {
269- constructor ( _selector : Type | string , { descendants = false } : { descendants ?: boolean } = { } ) {
270- super ( _selector , { descendants : descendants } ) ;
297+ constructor ( _selector : Type | string ,
298+ { descendants = false , first = false } : { descendants ?: boolean , first ?: boolean } = { } ) {
299+ super ( _selector , { descendants : descendants , first : first } ) ;
271300 }
272301
273302 /**
@@ -302,3 +331,29 @@ export class ViewQueryMetadata extends QueryMetadata {
302331export class ViewChildrenMetadata extends ViewQueryMetadata {
303332 constructor ( _selector : Type | string ) { super ( _selector , { descendants : true } ) ; }
304333}
334+
335+ /**
336+ * Configures a view query.
337+ *
338+ * View queries are set before the `afterViewInit` callback is called.
339+ *
340+ * ### Example
341+ *
342+ * ```
343+ * @Component ({
344+ * selector: 'someDir'
345+ * })
346+ * @View ({templateUrl: 'someTemplate', directives: [ItemDirective]})
347+ * class SomeDir {
348+ * @ViewChild (ItemDirective) viewChild:ItemDirective;
349+ *
350+ * afterViewInit() {
351+ * // viewChild is set
352+ * }
353+ * }
354+ * ```
355+ */
356+ @CONST ( )
357+ export class ViewChildMetadata extends ViewQueryMetadata {
358+ constructor ( _selector : Type | string ) { super ( _selector , { descendants : true , first : true } ) ; }
359+ }
0 commit comments