ViewQuery: QueryFactory

export ViewQuery : QueryFactory

exported from angular2/core defined in angular2/src/core/metadata.ts (line 1185)

Similar to QueryMetadata, but querying the component view, instead of the content children.

Example (live demo)

@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 QueryMetadata, except descendants. This always queries the whole view.

As shown is flipped between true and false, items will contain zero of one items.

Specifies that a QueryList should be injected.

The injected object is an iterable and observable live list. See QueryList for more details.