Similar to Query, but querying the component view, instead of the content children.
Example
@Component(
selector: 'my-component',
template: '''
<template [ngIf]="shouldShow">
<item> a </item>
<item> b </item>
<item> c </item>
</template>
'''
)
class MyComponent {
boolean shouldShow;
MyComponent(@ViewQuery(Item) QueryList<Item> items) {
items.changes.listen((_) => print(items.length));
}
}
Supports the same querying parameters as Query, except
descendants
. This always queries the whole view.
As shouldShow
is flipped between true and false, items will contain zero
or three items.
Specifies that a QueryList
should be injected.
The injected object is an iterable and observable live list. See
QueryList
for more details.
- Inheritance
- Object
- DependencyMetadata
- Query
- ViewQuery
- Implemented by
Constructors
- ViewQuery(_selector, { bool descendants: false, bool first: false, read: null })
-
const
Properties
- descendants → bool
-
whether we want to query only direct children (false) or all children (true).
read-only, inherited - first → bool
-
read-only, inherited
- hashCode → int
-
Get a hash code for this object.
read-only, inherited - isVarBindingQuery → bool
-
Whether this is querying for a variable binding or a directive.
read-only, inherited - isViewQuery → dynamic
-
Always
true
to differentiate it withQuery
.read-only - read → dynamic
-
The DI token to read from an element that matches the selector.
read-only, inherited - runtimeType → Type
-
A representation of the runtime type of the object.
read-only, inherited - selector → dynamic
-
read-only, inherited
- token → dynamic
-
read-only, inherited
- varBindings → List
-
A list of variable bindings this is querying for.
read-only, inherited
Operators
-
operator ==(
other) → bool -
The equality operator.
inherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a non-existent method or property is accessed.
inherited -
toString(
) → String -
Returns a string representation of this object.