W3cubDocs

/Angular 2

QueryList

Stable Class

Class Overview

class QueryList {
  changes : Observable<any>
  length : number
  first : T
  last : T
  map(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
  reduce(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()
  dirty 
}

Class Description

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

The type of object that Query and ViewQueryMetadata 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>;
}

Class Details

changes : Observable<any>
length : number
first : T
last : T
map(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

See Array.find

reduce(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

dirty

internal

exported from @angular/core/index, defined in @angular/core/src/linker/query_list.ts

© 2010–2017 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://v2.angular.io/docs/ts/latest/api/core/index/QueryList-class.html