Reputation: 9247
In my loginService i have this:
getUserData(): any { return this.userData; }
What i want is to get that in logsService:
data = this.getUserData();
return this.http.get('/api/logs' + data.user.email)
// ...and calling .json() on the response to return data
.map((res:Response) => res.json())
//...errors if any
.catch((error:any) => Observable.throw(error.json().error || 'Server error'));
}
Is that possible?
Upvotes: 0
Views: 63
Reputation: 5374
It's possible. You should inject service in constructor, in the same way as inject service to component, f.e.
@Injectable()
export class FirstService {
constructor(
private _secondService: SecondService
){}
}
@Injectable()
export class SecondService {
constructor( ){}
}
Upvotes: 1