How can I get children elements from QueryList in Angular 2? How can I get children elements from QueryList in Angular 2? angular angular

How can I get children elements from QueryList in Angular 2?


If clients is set from an async call (for example to the server) then the elements don't exist in ngAfterViewInit() yet.

You can use

ngAfterViewInit() {  this.processingItems.changes.subscribe(() => {    this.processingItems.toArray().forEach(el => {        console.log(el);    });  });}

See also https://angular.io/api/core/QueryList#changes


I think you should be using the @ContentChildren attribute instead of the ViewChildren.

@ContentChildren( OptionComponent )public Options: QueryList<OptionComponent>;