Show progress circular during $http post?

后端 未结 7 1593
旧巷少年郎
旧巷少年郎 2021-02-08 15:56

What is the best way to use Angular Material\'s Progress circular component with a $http request?

I currently have the code like this below:

Progre

7条回答
  •  失恋的感觉
    2021-02-08 16:34

    If you want to watch the progress of post data use uploadEventHandlers

    There is an example.

    $http({
        method: 'POST',
        url: '/uploadToFtp',
        headers: {
            'Content-Type': undefined
        },
        eventHandlers: {
            progress: function(c) {
                //console.log('Progress -> ' + c);
                //console.log(c);
            }
        },
        uploadEventHandlers: {
            progress: function(e) {
                //console.log('UploadProgress -> ' + e);
                //console.log(e);
                _self.progressValue = (e.loaded / e.total) * 100.0;
            }
        },
        data: postData,
        transformRequest: angular.identity
    })
    .then(callBack,errorCallBack)
    .catch(errorCallBack);
    

    Show the progress circular like this

    
    

提交回复
热议问题