How to assign an observable string array value to a string array?

Viewed 31

I have an observable with an array of ids in it and an empty array. I tried to subscribe to the observable and then assign the observable array to the empty array but the empty is undefined when I console log it.

testIds$ = this.tests$.pipe(
        map(at => at.map(id => id.testIds)),
    );
testIds : number[];

  

ngOnInit() {
    this.testIds$.subscribe(val => this.testIds = val);
    console.log(this.testIds$.subscribe(val => console.log("Val: ", val)));
}
0 Answers
Related