There are two functions at play here. The first function returns a result stored in a variable, which is then passed as a parameter to the second function to call a service. The issue is that when these functions are invoked within ngOnInit, the second function is unable to capture the result stored in the variable from the first function. Is there a way to overcome this problem?
TS code:
udata:string;
ngOninit(){
this.f1();
this.f2();
}
f1(){
this.service.getudata().subscribe(res => {
this.udata = res;
});
}
f2(){
this.service.getudatas(this.udata).subscribe(res => {
const data = res;
});
}