export class QueryMetadata
export class QueryMetadata
exported from angular2/core defined in angular2/src/core/metadata/di.ts (line 35)
Declares an injectable parameter to be a live list of directives or variable bindings from the content children of a directive.
Example (live demo)
Assume that <tabs>
component would like to get a list its children <pane>
components as shown in this example:
The preferred solution is to query for Pane
directives using this decorator.
A query can look for variable bindings by passing in a string with desired binding symbol.
Example (live demo)
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.
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)
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 QueryList
for more details.
Constructor
constructor(_selector: Type | string, {descendants = false, first = false}?: {descendants?: boolean, first?: boolean})
constructor(_selector: Type | string, {descendants = false, first = false}?: {descendants?: boolean, first?: boolean})
Not Yet Documented
Members
descendants : boolean
descendants : boolean
whether we want to query only direct children (false) or all children (true).
first : boolean
first : boolean
Not Yet Documented
isViewQuery : boolean
isViewQuery : boolean
always false
to differentiate it with ViewQueryMetadata
.
selector
selector
what this is querying for.
isVarBindingQuery : boolean
isVarBindingQuery : boolean
whether this is querying for a variable binding or a directive.
varBindings : string[]
varBindings : string[]
returns a list of variable bindings this is querying for. Only applicable if this is a variable bindings query.
toString() : string
toString() : string
Not Yet Documented