Can you please answer to question in comment
class TextComp
{
result: string;
constructor() {
this.getdata().subscribe(result => {
console.log("result received");
this.result = result;
});
console.log("called before result received " + this.result);
//this.result is NULL/UNDEFINED because this line executed before data received
// So how we can eliminate this situation??? or
// Is there any way to make synchronus call to http in angular 2
}
getdata() {
return http.get('test.json')
.map(response => response.json());
}
}
So how we can eliminate this situation??? or Is there any way to make synchronus call to http in angular 2