I am newbie at Angular2. In my view I have few identical children that are generated in *ngFor.
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>;