I have a query regarding Angular 2. I am new to this framework and I attempted to store a simple value in a variable by calling a get method that retrieves a number from the backend written in C#. How can I save this returned value in a global variable?
getTarea(a,b,c,d,e){
return this._http.get('http://localhost:50790/ApiProductoTipo/TareaPT?delegacionId='+a+'&municipioId='+b+'&ejercicioId='+c+'&ninternoId='+d+'&tipo='+e)
.map(res=> {alert('Tarea:'+res);})
.catch(this.handleError);
}
This snippet displays
Tarea:Response with status: 200 OK for URL: http://localhost:50790/ApiProductoTipo/TareaPT?delegacionId=11&municipioId=1&ejercicioId=2017&ninternoId=-1&tipo=T
However, my requirement is to obtain the numerical value returned by this method. Any suggestions on how to achieve this?
Back
[HttpGet]
public int GetTareaPT(int delegacionId, int municipioId, int ejercicioId, int ninternoId, string tipo)
{
int numtarea = this.productoTipoService.GetTareaPT(delegacionId, municipioId, ejercicioId, ninternoId, tipo);
if (numtarea != 0)
{
return numtarea;
}
else
{
return 0;
}
}