• HTTP 进度事件
    • 进度事件

    HTTP 进度事件

    reportProgress选项设置为true,可以对进度事件进行跟踪。

    ⚠️每个进度事件都会触发更改检测。

    进度事件

    1. longRequest() {
    2. const request = new HttpRequest(
    3. "POST", "/api/test-request", {},
    4. {reportProgress: true});
    5. this.http.request(request)
    6. .subscribe(
    7. event => {
    8. if (event.type === HttpEventType.DownloadProgress) {
    9. console.log("Download progress event", event);
    10. }
    11. if (event.type === HttpEventType.UploadProgress) {
    12. console.log("Upload progress event", event);
    13. }
    14. if (event.type === HttpEventType.Response) {
    15. console.log("response received...", event.body);
    16. }
    17. }
    18. );
    19. }