QueryList

class

npm Package @angular/core
Module import { QueryList } from '@angular/core';
Source core/src/linker/query_list.ts

Overview

class QueryList<T> {
  get changes: Observable<any>
  get length: number
  get first: T
  get last: T
  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(res: Array<T|any[]>): void
  notifyOnChanges(): void
  setDirty()
  get dirty
  destroy(): void
}

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 *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.

Example (live demo)

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

Members

get changes: Observable<any>

get length: number

get first: T

get last: T

map<U>(fn: (item: T, index: number, array: T[]) => U): U[]

See Array.map

filter(fn: (item: T, index: number, array: T[]) => boolean): T[]

See Array.filter

find(fn: (item: T, index: number, array: T[]) => boolean): T|undefined

See Array.find

reduce<U>(fn: (prevValue: U, curValue: T, curIndex: number, array: T[]) => U, init: U): U

See Array.reduce

forEach(fn: (item: T, index: number, array: T[]) => void): void

See Array.forEach

some(fn: (value: T, index: number, array: T[]) => boolean): boolean

See Array.some

toArray(): T[]

toString(): string

reset(res: Array<T|any[]>): void

notifyOnChanges(): void

setDirty()

internal

get dirty

internal

destroy(): void

internal

© 2010–2017 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://v4.angular.io/api/core/QueryList