0
angular2와 observables에 대한 질문이 있습니다. 서비스에서 observable (다른 서비스에서로드)로 작업 한 다음 관찰 가능 데이터로 데이터를 반환하려고합니다.각도 2 : 관측 가능하고 작업 가능 관측 가능
어떻게하면됩니까? 이 코드가 있습니다
getEPGDayByChannel(channelID, newDate) {
let mydate = new Date(newDate.getFullYear(), newDate.getMonth(), newDate.getDate(), 0, 0, 0);
let fromDate = new Date(mydate.getFullYear(), mydate.getMonth(), mydate.getDate(), 0, 0, 0);
let endDate = new Date(mydate.getFullYear(), mydate.getMonth(), mydate.getDate(), 23, 59, 59);
this.apiService.getChannelEPGbyTime(channelID, fromDate, endDate).
subscribe(
data => {
//do some magic with the data
// return some thing of the data as an observable
return Observable.of(data.programme);
},
error => { this.variables.setFailure(error);}
);
}
을하지만이 코드 나는이 실패 얻을 :
EXCEPTION: Uncaught (in promise): TypeError: this.epgService.getEPGDayByChannel(...) is undefined
Unhandled Promise rejection: this.epgService.getEPGDayByChannel(...) is undefined ; Zone: angular ; Task: Promise.then ; Value: TypeError: this.epgService.getEPGDayByChannel(...) is undefined
내가 어떤 도움을 매우 기쁘게 것을!
정말? : D 다 괜찮아, 고마워! 하루 종일이 보낸^^ 고마워! – Junias
@Junias 예, 간단합니다. 그러나'getEPGDayByChannel' 메소드를 호출하자 마자'apiService.getChannelEPGbyTime'가 호출되지 않는다는 것을 이해해야한다. 귀하의 코드는 구독하지 않고 apiService를 호출함으로써 apiService를 호출했습니다. – olivarra1