Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- getResult (): Observable<result[]> {
- return this.http.get(this.url)
- .map(this.extractData)
- .catch(this.handleError);
- }
- private extractData(res: Response) {
- let body = res.json();
- // save the data in the service
- this.data = body;
- return body || { };
- }
- getData() {
- this.data // undefeind !!!!
- }
- this.myService.getResult()
- .subscribe(res => {this.data= res;
- },
- error => {
- console.log("error on getData function: " + error);
- }
- );
- getResult (): Observable<result[]> {
- return this.http.get(this.url)
- .map((res)=>this.extractData(res))
- .catch((err)=>this.handleError(err));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement