Hello I want to download the json data from server and then assign the data to the globally available variable.
I did something like this:
import {Injectable} from '@angular/core';
import { Http, Headers, RequestOptions } from '@angular/http';
@Injectable()
export class GlobalService {
public loginState:boolean = false;
public player: any = [];
constructor(public http: Http) {
this.http.get('http://localhost/ionic/retrieve-data.php')
.map(res => res.json())
.subscribe(data =>
{
this.player = data;
console.log(this.player.user);
});
}
}
and in other pages i inject it in constructor, but all i can see is empty variable player, loginstate is working.
How can I get the data ti the variable, so I can see this in other pages?