I have a dynamic array of ng-select controls. Each control represented by class NgSelectComponent.
When select value changes I want to subscribe to all controls.
Template
<ng-select #select">
<ng-option *ngFor="let option of options" [value]="select.id">{{ option.name }}</ng-option>
</ng-select>
Class
@ViewChildren('select') controls: QueryList<NgSelectComponent>;
ngAfterViewInit() {
concat(this.controls.toArray()).subscribe(x => {
console.log(x);
});
}
I try that, but does not work.
concat(this.components.toArray()).subscribe(x => {
console.log(x);
});
I believe it does not work because I had to subscribe to the values produced by each control corresponded by changeEvent but struggling to do that.
Any ideas how to solve?