I have an angular component that calls a service. The component has a method like this:
componentDoThing(id){
this.member = this.service.getSomeValue(id);
console.log("component: member: " + this.member);
//member is undefined
}
And the service:
getSomeValue(id){
local_http_method.get(/some/url)
.then(result => {this.something = result});
console.log("service: this.something:" + this.something);
// this.something is {"foo":"bar","1":"3"}
return this.something;
Why is the value undefined in the component, but perfectly well defined in the service?