Hi Celerity,
If you want synchronous results, you need to use native JS, as Angular
doesn't provide that.
However, you can easily string multiple async calls together.
might look like this:
import { Injectable } from '@angular/core';
import { Http, Headers, Response } from '@angular/http';
@Injectable()
export class ServiceNameService {
constructor(private http:Http) { }
getResult() {
return this.firststep()
.map(this.secondstep)
.map(this.thirthstep)
.subscribe(data => {
/* all data is available here */
});
}
firststep() {
return this.http.get('url')
.map((response: Response) => response.json())
.map(data => ({firstep: data}))
;
}
secondstep(data) {
/* use data to prepare call */
return this.http.get('url')
.map((response: Response) => response.json())
.map((r) => data.secondStep = r);
}
thirthstep(data) {
/* use data to prepare call */
return this.http.get('url')
.map((response: Response) => response.json())
.map((r) => data.thirthStep = r);
}
}
Hope this helps you a bit,
Regards
Sander
--
You received this message because you are subscribed to the Google Groups
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.