Hello please can you help me on this problem I m new in Angular and TS.
I have a function that I need to send it like an output parameter because in the next step I will call it from other component.
My problem now that I get the good result only inside the function but outside I get 2undefined.
I have the commented line this.tab= result;
work but I need to send the result first like a parameter because after i will call this function from other component.
Thanks in advance.
export class A implements OnInit {
tab= [];
ngOnInit(): void {
this.getResult(this.isDeprecated,this.tab);
console.debug('2'+this.tab); **//2undefined**
}
getResult(isDeprecated: boolean,wl:any) {
this.Service1.GetOnly(isDeprecated).subscribe(
(result) => {
if (result) {
// this.tab= result; **It work**
wl= result;
console.debug('1'+result); **//I get result only inside function**
}
},
(error) => {
console.log(error);
}
);
}