Angular4_ Observable和subscribe

getHUs = (request:HandlingUnitsRequest):Observable=> {
if (this.chbCheckkAll) {
this.chbCheckkAll.nativeElement.checked='';
}
const response = this.service.handlingUnits(request);
response.subscribe((data:any[])=> {
this.onDataLoaded.emit(data.length!==0);
console.log('getHUsData:'+ JSON.stringify(data));
}, (err => {
console.log(err);
})
, () => {
console.log('SUccessssss');
this.service.handlingUnitFilter().subscribe((res:any)=> {
this.handlingUnitFilter=res;
console.log(res);
});
});
return response;
};


  /**
     * Registers handlers for handling emitted values, error and completions from the observable, and
     *  executes the observable's subscriber function, which will take action to set up the underlying data stream
     * @method subscribe
     * @param {PartialObserver|Function} observerOrNext (optional) either an observer defining all functions to be called,
     *  or the first of three possible handlers, which is the handler for each value emitted from the observable.
     * @param {Function} error (optional) a handler for a terminal event resulting from an error. If no error handler is provided,
     *  the error will be thrown as unhandled
     * @param {Function} complete (optional) a handler for a terminal event resulting from successful completion.
     * @return {ISubscription} a subscription reference to the registered handlers
     */
    subscribe(): Subscription;
    subscribe(observer: PartialObserver): Subscription;
    subscribe(next?: (value: T) => void, error?: (error: any) => void, complete?: () => void): Subscription;
    protected _trySubscribe(sink: Subscriber): TeardownLogic;

你可能感兴趣的:(Angular2.x)