I'm using the latest angular, imports and other angular things are normal. I have such code:
...class definition
ngOnInit(){
this.http.get("http://localhost:5000/getData").subscribe(data => {
this.data = data;
});
}
Where localhost:5000/getData returns data in json. And angular is on the http://localhost:4200/ and it has its own routers. The data is correct, but I'm unable to use this.data outside the subscribe() method(no errors just this.data field is empty). Where am I wrong? What should I do to fix it?(I fixed troubles with same origin policy because other things work in normal way). I have to display data from the server into my component;
this.datathis.datahas value, but outside subscribethis.datahas no value again. I use it in my component