Angular4_ Observable和subscribe
发布时间:2020-12-17 08:36:58 所属栏目:安全 来源:网络整理
导读:getHUs = (request : HandlingUnitsRequest ) : Observable any = { if ( this . chbCheckkAll ) { this . chbCheckkAll . nativeElement .checked = '' ; } const response = this . service . handlingUnits ( request ); response . subscribe ((data : a
|
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;
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
