Skip to content

Commit b231146

Browse files
committed
apiBase inject into hero service
1 parent 9cdbf18 commit b231146

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/app/shared/services/hero/hero.service.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Injectable } from '@angular/core'; // because we want to be able to inject our hero service
1+
import { Injectable, Inject } from '@angular/core'; // because we want to be able to inject our hero service
22
import { Http, Response, RequestOptionsArgs } from '@angular/http';
33
import { Observable } from 'rxjs/Observable';
44

@@ -9,9 +9,8 @@ import { Hero } from './hero';
99

1010
@Injectable()
1111
export class HeroService {
12-
constructor (private http: Http) {}
12+
constructor (private http: Http, @Inject('apiBase') private _apiBase: string) {}
1313

14-
private _apiBase = 'https://angular2-login-seed.herokuapp.com';
1514
private _heroesUrl = this._apiBase + '/api/heroes';
1615

1716
getHeroes () {
@@ -26,11 +25,11 @@ export class HeroService {
2625
heroes => heroes.filter(hero => hero.id === id)[0]
2726
);
2827
}
29-
28+
3029
private handleError (error: Response) {
3130
// in a real world app, we may send the server to some remote logging infrastructure
3231
// instead of just logging it to the console
3332
console.error(error);
3433
return Observable.throw(error.json().error || 'Server error');
3534
}
36-
}
35+
}

0 commit comments

Comments
 (0)