export class PropertiesService {
getCommonProperties():any{
let URL: string = "/xxxx/yyyyy";
let headers = new Headers();
let options = new RequestOptions({ headers });
options.method = GET;
return this.http.request(URL, options).map(response => {
{
console.log("response ", response.json());
return response.json();
};
}
}
/**************************/
export class A {
this.commonProperties.setPropertiesMap(
this.propertiesService.getCommonProperties().subscribe(result =>
{ return result;})
);
//logic to iterate commonPropertiesMap
}
/*PropertiesMap is a map which stores a key value pair of some properties,I have a service named propertiesService where i get the stream of properties from the server, and i have to set the result into properties map. I am getting the result from server(i could see it in the console ) where as the control is passing to the next step even before i get the response from the server, so there is an error thrown that the PropertiesMap is not iterable. Can someone help me with the logic to hold the control until i get the result from HTTP request and set the values into the PropertiesMap and then iterate through the map?? */