Skip to content

Instantly share code, notes, and snippets.

@lx4r
Created April 24, 2016 08:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lx4r/36630d65ccf558fee1852ebd390821cf to your computer and use it in GitHub Desktop.
Save lx4r/36630d65ccf558fee1852ebd390821cf to your computer and use it in GitHub Desktop.
import {Injectable, Component} from 'angular2/core';
import {Http, Headers} from 'angular2/http';
import {Game} from "../interfaces/game";
import {SettingsService} from "./settings-service";
@Injectable()
@Component({
providers: [SettingsService]
})
export class GameService {
_settings: SettingsService;
constructor(private _http: Http) {
this._settings = new SettingsService();
}
getDetails(game: Game){
let promise = new Promise(
(resolve) => {
console.log("getDetails: promise started");
this._settings.getServerURL().then(
serverURL => {
console.log("getDetails: get data with " + serverURL);
this._http.get(serverURL + '/api.php?request=detail&id=' + game.id).subscribe(
secondData => resolve(secondData)
);
}
);
}
);
return promise;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment