I'm having a problem with the following function.
retornaCantidadActual(itemProducto) {
this.prodserv.getProdObservable(itemProducto).subscribe(dataprod => {
const xxprod = dataprod;
console.log('Funcion retornaCantidadActual =====>', xxprod[0].cantidadActual);
return xxprod[0].cantidadActual;
});
}
This function is within an Angular 6 component and is using firebase. As you can see, the console log that is inside the function responds correctly or is taking the value well. The getProdObservable is in the service and returns an observable with a single record that is the product passed by parameter to the function. The problem is when I call this function from another place in the program because it returns to me in console "undefined" and obviously does not take any value, but I should return the value it shows internally, I do not understand what I'm doing wrong. I thank you in advance and send a cordial greeting. Atte Marcelo.