[ Web Proxy ]
URL:
Viewing: https://angular.dev/api/core/QueryList [Back]  [Original]

QueryList Angular Skip to main content
menu
close
more_horiz
menuAPI
@angular/core

QueryList

Class
stable

An unmodifiable list of items that Angular keeps up to date when the state of the application changes.

Using QueryList

On this page

    arrow_upward_alt Back to the top

    API

        
          class QueryList<T> implements Iterable<T> {  constructor(_emitDistinctChangesOnly?: boolean);  readonly dirty: true;  readonly length: number;  readonly first: T;  readonly last: T;  readonly changes: Observable<any>;  get(index: number): T | undefined;  map<U>(fn: (item: T, index: number, array: T[]) => U): U[];
    filter<S extends T>(predicate: (value: T, index: number, array: readonly T[]) => value is S): S[]; filter(predicate: (value: T, index: number, array: readonly T[]) => unknown): 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) | undefined): void; notifyOnChanges(): void; setDirty(): void; destroy(): void; [Symbol.iterator]: () => Iterator<T, any, any>;}

    constructor

    QueryList<T>
    @param_emitDistinctChangesOnlyboolean
    @returnsQueryList<T>

    dirty

    true

    length

    number

    changes

    Observable<any>

    Returns Observable of QueryList notifying the subscriber of changes.

    get

    T | undefined

    Returns the QueryList entry at index.

    @paramindexnumber
    @returnsT | undefined

    map

    U[]
    @paramfn(item: T, index: number, array: T[]) => U
    @returnsU[]

    filter

    2 overloads
    @parampredicate(value: T, index: number, array: readonly T[]) => value is S
    @returnsS[]
    @parampredicate(value: T, index: number, array: readonly T[]) => unknown
    @returnsT[]

    find

    T | undefined
    @paramfn(item: T, index: number, array: T[]) => boolean
    @returnsT | undefined

    reduce

    U
    @paramfn(prevValue: U, curValue: T, curIndex: number, array: T[]) => U
    @paraminitU
    @returnsU

    forEach

    void
    @paramfn(item: T, index: number, array: T[]) => void
    @returnsvoid

    some

    boolean
    @paramfn(value: T, index: number, array: T[]) => boolean
    @returnsboolean

    toArray

    T[]

    Returns a copy of the internal results list as an Array.

    @returnsT[]

    toString

    string
    @returnsstring

    reset

    void

    Updates the stored data of the query list, and resets the dirty flag to false, so that on change detection, it will not notify of changes to the queries, unless a new change occurs.

    @paramresultsTree(any[] | T)[]

    The query results to store

    @paramidentityAccessor((value: T) => unknown) | undefined

    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 reset function) to detect if the lists are different. If the function is not provided, elements are compared as is (without any pre-processing).

    @returnsvoid

    notifyOnChanges

    void

    Triggers a change event by emitting on the changes EventEmitter.

    @returnsvoid

    setDirty

    void

    internal

    @returnsvoid

    destroy

    void

    internal

    @returnsvoid

    [Symbol.iterator]

    () => Iterator<T, any, any>

    Description

    An unmodifiable list of items that Angular keeps up to date when the state of the application changes.

    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 @for(i of myList; track $index).

    Changes can be observed by subscribing to the changes Observable. *

    Usage Notes

    Example

    @Component({...})
    class Container {
      @ViewChildren(Item) items:QueryList<Item>;
    }
    Jump to details

    Web Proxy Viewer  |  New URL  |  Original Page