Angular4_ Observable和subscribe

前端之家收集整理的这篇文章主要介绍了Angular4_ Observable和subscribe前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
getHUs = (request : HandlingUnitsRequest) : Observable< any> => {
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<T>): Subscription;
    subscribe(next?: (value: T) => void,error?: (error: any) => void,complete?: () => void): Subscription;
    protected _trySubscribe(sink: Subscriber<T>): TeardownLogic;
原文链接:https://www.f2er.com/angularjs/145603.html

猜你在找的Angularjs相关文章