So I have two variables in my Typescript class:
private myServiceSubscription: Subscription;
myVar: myDto[] = [];
In the ctor:
this.myServiceSubscription = this.deliveryPointService
.getPostalAddresses()
.subscribe(result => console.log(result));
I can see the expected result returned from the service in the console log (a list with two items) However, if I use another subscribe instead:
.subscribe(result => this.myVar);
and (outside the subscribe): console.log(this.myVar[0]);
then I notice this.myVar is undefined.
Why does console.log(result) show the right result, but this.myVar does not?
This is in angular 4.