I have a problem.
It happens that I have a json data that I receive from the database, and when entering the service that the json brings me I enter the subscribe and assign the data json to a variable. but the problem is that using the variable a to which the json assigned in this case of llama this.datos, if it leaves the subscribe is already empty, but within it is with the json that you assign.
I would like to know how I do this this data contains the json that I assign in the subscribe to use in other functions or operations.
This is the service call the json brings:
getDatos(){
this._service.getDatos.subscribe(
result => {
if(result.code = 200){
this.datos = result.data;
console.log(this.datos);
}else{
console.log(result);
}
},
error => {
console.log(<any>error);
}
);
}
This is the get service:
get getDatos(){
return this._http.get(this.url+'*').map(res => res.json());
}
What I want is to use this data with the json assigned to it.
The variable this.data is declared at the beginning of the component.
Thanks