У меня та же проблема, что и в сообщении SO здесь Я получаю неопределенность в методе подписки в моем component.ts, хотя в моей службе у меня есть данные. См. коды ниже p.component.ts
private getPayItems():void{
console.log('In getPayItems');
this._payItemService.getPayItems()
.subscribe(data => {
this.payItemArray = data;
console.log(data);
},
(error:any) =>{
this.alerts.push({ msg: error, type: 'danger', closable: true });
})
}
p.service.ts
getPayItems():Observable<Payitem[]>{
let actionUrl = this.url + "/GetPayItem";
return this._http.get(actionUrl, { headers: this.headers })
.map((response: Response) => {
<Payitem[]>response.json() ;
console.log(<Payitem[]>response.json()); //This logs the Object
})
.catch(this.handleError);
}