我正在切换我的服务调用以使用新的HttpClient。我有三件事情挣扎Angular HttpClient - 在等待服务响应时显示微调器/进度指示器 - 进度事件
- 图如何显示微调/进度条/等,同时等待 从一个帖子,GET,PUT的响应。
- 假响应缓慢
- 是否可以使用新的进度事件来触发此类功能?
application.component.ts
this.applicationFormService.putForm(formModel)
.subscribe(
// Successful responses call the first callback.
(res) => this.goToRoute(res),
// Errors will call this callback instead:
(err: HttpErrorResponse) => {
if (err.error instanceof Error) {
console.log("Client-side error occured.");
} else {
console.log("Server-side error occured.");
}
},
//Tried adding progress event logic here but I get error Argument of type '(event: any) => void' is not assignable to parameter of type '() => void'. Is this totally the wrong implementation and can it even be used for showing progress?
event => {
// Via this API, you get access to the raw event stream.
// Look for upload progress events.
if (event.type === HttpEventType.UploadProgress) {
// This is an upload progress event.
} else if (event instanceof HttpResponse) {
}
}
)
application.service.ts
constructor (private httpNew: HttpClient){}
putForm(applicationForm:any){
this.applicationId = this.id.id
const req = new HttpRequest('PUT', this.applicationSubmitUrl+this.applicationId, applicationForm, {
reportProgress: true,
});
return this.httpNew.request(req)
}
这正是我在问候寻找问题#1将共享解决方案,我想出了与我结合你的答案。谢谢! – Anthony
那么你需要更多的帮助吗? – Aravind
认为我很好。看到我发布的答案。 – Anthony