I need to set myVariable value indicated inside the function load(), where I collect a data from the service and show it in another function (otrafuncion()), but I don't know the syntax.
export class clase{
public this.miVariable:any;
constructor(){}
ngOnload():void{
this.load();
this.otraFuncion();
}
load() {
this.loadService.cargar().subscribe(
(respuesta) => {
this.carga = respuesta;
this.miVariable=this.carga.mivalorRecogido; //necesito este valor
}
);
}
}
otrafuncion(){
console.log(this.miVariable);
}
}