admin管理员组文章数量:1420929
I'm having an issue with an observable :
In a service I have a function (in editponent):
public patchOne(entity: Tier): Observable<any> {
const userData: any = this.httpService.getDataFromLocalStorage(AuthService.LOCAL_STORAGE_USER_TAG);
return this.httpService.patch(`/someurl/${entity.uid}`, {
params: {
user_uid: JSON.parse(userData).userUId,
},
body: entity.createPatchTier(),
}).map((res: any) => {
// TODO : to plete
return {};
}).catch((error: any) => Observable.throw('patchOne - ', error.json().errorMessage || 'Server error'));
}
Calling it from ponent (in editponent):
onSave() {
if (this.validateFormData()) {
this.tierService.patchOne(this._item).subscribe(() => {
this.appCommunicationService.valid('Success');
}, (error: any) => {
this.appCommunicationService.error(error.message);
});
} else {
this.appCommunicationService.info('Fail');
}
}
Triggered from a button with this property (ViewComponent.html):
(click)="ponent.onSave()"
I'm having this error uppon clicking :
ERROR TypeError: scheduler.schedule is not a function
at ErrorObservable.webpackJsonp.../../../../rxjs/observable/ErrorObservable.js.ErrorObservable._subscribe (ErrorObservable.js:72)
[...]
webpackJsonp.../../../../../src/app/ponents/edit/editponent.ts.EditTiersComponent.onSave @ editponent.ts:99
(anonymous) @ ViewComponent.html:14
Any idea ?
I'm having an issue with an observable :
In a service I have a function (in edit.ponent):
public patchOne(entity: Tier): Observable<any> {
const userData: any = this.httpService.getDataFromLocalStorage(AuthService.LOCAL_STORAGE_USER_TAG);
return this.httpService.patch(`/someurl/${entity.uid}`, {
params: {
user_uid: JSON.parse(userData).userUId,
},
body: entity.createPatchTier(),
}).map((res: any) => {
// TODO : to plete
return {};
}).catch((error: any) => Observable.throw('patchOne - ', error.json().errorMessage || 'Server error'));
}
Calling it from ponent (in edit.ponent):
onSave() {
if (this.validateFormData()) {
this.tierService.patchOne(this._item).subscribe(() => {
this.appCommunicationService.valid('Success');
}, (error: any) => {
this.appCommunicationService.error(error.message);
});
} else {
this.appCommunicationService.info('Fail');
}
}
Triggered from a button with this property (ViewComponent.html):
(click)="ponent.onSave()"
I'm having this error uppon clicking :
ERROR TypeError: scheduler.schedule is not a function
at ErrorObservable.webpackJsonp.../../../../rxjs/observable/ErrorObservable.js.ErrorObservable._subscribe (ErrorObservable.js:72)
[...]
webpackJsonp.../../../../../src/app/ponents/edit/edit.ponent.ts.EditTiersComponent.onSave @ edit.ponent.ts:99
(anonymous) @ ViewComponent.html:14
Any idea ?
Share Improve this question edited Dec 12, 2017 at 13:10 An-droid asked Dec 12, 2017 at 12:56 An-droidAn-droid 6,48510 gold badges51 silver badges95 bronze badges1 Answer
Reset to default 7Looks like you have an error on this line:
.catch((error: any) => Observable.throw('patchOne - ', error.json().errorMessage || 'Server error'));
The Observable.throw
has the following signature:
public static throw(error: any, scheduler: Scheduler): Observable
As you can see, the 2nd parameter is the scheduler
. In your code, you're providing this 2nd parameter, so ultimately RxJs is trying to invoke schedule
on your string (error.json().errorMessage || 'Server error'
).
You need to update your error message to use string concatenation. e.g.:
'patchOne - ' + (error.json().errorMessage || 'Server error'))
Or perhaps using string interpolation:
`patchOne - ${(error.json().errorMessage || 'Server error')}`
本文标签: javascriptAngular quotschedulerschedule is not a functionquot using observableStack Overflow
版权声明:本文标题:javascript - Angular "scheduler.schedule is not a function" using observable - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745320675a2653363.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论