On this page
QueryList
class  final 
An unmodifiable list of items that Angular keeps up to date when the state of the application changes.
class QueryList<T> implements Iterable<T> {
  constructor(_emitDistinctChangesOnly: boolean = false)
  dirty: true
  length: number
  first: T
  last: T
  changes: Observable<any>
  get(index: number): T | undefined
  map<U>(fn: (item: T, index: number, array: T[]) => U): U[]
  filter(fn: (item: T, index: number, array: T[]) => boolean): T[]
  find(fn: (item: T, index: number, array: T[]) => boolean): T | undefined
  reduce<U>(fn: (prevValue: U, curValue: T, curIndex: number, array: T[]) => U, init: U): U
  forEach(fn: (item: T, index: number, array: T[]) => void): void
  some(fn: (value: T, index: number, array: T[]) => boolean): boolean
  toArray(): T[]
  toString(): string
  reset(resultsTree: (any[] | T)[], identityAccessor?: (value: T) => unknown): void
  notifyOnChanges(): void
  setDirty()
  destroy(): void
}
   Description
The type of object that ViewChildren, ContentChildren, and QueryList provide.
Implements an iterable interface, therefore it can be used in both ES6 javascript for (var i of items) loops as well as in Angular templates with *ngFor="let i of myList".
Changes can be observed by subscribing to the changes Observable.
NOTE: In the future this class will implement an Observable interface.
Further information is available in the Usage Notes...
Constructor
        
          | 
      
_emitDistinctChangesOnly | 
            boolean | 
            Optional. Default is   | 
           
Properties
| Property | Description | 
|---|---|
dirty: true | 
       Read-Only | 
length: number | 
       Read-Only | 
first: T | 
       Read-Only | 
last: T | 
       Read-Only | 
changes: Observable<any> | 
       Read-Only  Returns   | 
      
Methods
| 
         
         get()
          | 
      |||
|---|---|---|---|
Returns the QueryList entry at   | 
      |||
        
          | 
      
index | 
            number | 
            
Returns
T | undefined
| 
         
         map()
          | 
      |||
|---|---|---|---|
See Array.map  | 
      |||
        
          | 
      
fn | 
            (item: T, index: number, array: T[]) => U | 
            
Returns
U[]
| 
         
         filter()
          | 
      |||
|---|---|---|---|
See Array.filter  | 
      |||
        
          | 
      
fn | 
            (item: T, index: number, array: T[]) => boolean | 
            
Returns
T[]
| 
         
         find()
          | 
      |||
|---|---|---|---|
See Array.find  | 
      |||
        
          | 
      
fn | 
            (item: T, index: number, array: T[]) => boolean | 
            
Returns
T | undefined
| 
         
         reduce()
          | 
      ||||||
|---|---|---|---|---|---|---|
See Array.reduce  | 
      ||||||
        
          | 
      
fn | 
            (prevValue: U, curValue: T, curIndex: number, array: T[]) => U | 
            |
init | 
            U | 
            
Returns
U
| 
         
         forEach()
          | 
      |||
|---|---|---|---|
See Array.forEach  | 
      |||
        
          | 
      
fn | 
            (item: T, index: number, array: T[]) => void | 
            
Returns
void
| 
         
         some()
          | 
      |||
|---|---|---|---|
See Array.some  | 
      |||
        
          | 
      
fn | 
            (value: T, index: number, array: T[]) => boolean | 
            
Returns
boolean
| 
         
         toArray()
          | 
      
|---|
Returns a copy of the internal results list as an Array.  | 
      
        
          | 
      
| 
         
         toString()
          | 
      
|---|
        
          | 
      
| 
         
         reset()
          | 
      ||||||
|---|---|---|---|---|---|---|
Updates the stored data of the query list, and resets the   | 
      ||||||
        
          | 
      
resultsTree | 
            (any[] | T)[] | 
            The query results to store  | 
           
identityAccessor | 
            (value: T) => unknown | 
            Optional function for extracting stable object identity from a value in the array. This function is executed for each element of the query result list while comparing current query list with the new one (provided as a first argument of the  Optional. Default is   | 
           
Returns
void
| 
         
         notifyOnChanges()
          | 
      
|---|
Triggers a change event by emitting on the   | 
      
        
          | 
      
| 
         
         setDirty()
          | 
      
|---|
internal  | 
      
        
          | 
      
| 
         
         destroy()
          | 
      
|---|
internal  | 
      
        
          | 
      
Usage notes
Example
@Component({...})
class Container {
  @ViewChildren(Item) items:QueryList<Item>;
}
  © 2010–2022 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
 https://v13.angular.io/api/core/QueryList