P
P
Praud2017-03-21 17:25:29
JavaScript
Praud, 2017-03-21 17:25:29

How to display POST completion percentage in Angular 1.x?

Hello everyone, you need to display the progress bar with the percentage of the POST request completed. In the request, I pass the name of the template and the file extension, then the server generates it and returns it. Actually, while the generation process is going on, we need a progress bar.
I try like this

$http({
    method: 'POST',
    url: config.apiUrl + "/RevDoc/GenerateDocument",
    data: model,
    eventHandlers: {
        progress: function (e) {
            console.log(e);
            if (e.lengthComputable) {
                progress = Math.round(e.loaded * 100 / e.total);
                console.log("progress: " + progress + "%");
                if (e.loaded = e.total) {
                    console.log("File upload finished!");
                }
            }
        }
    },
}).then((response) => {
    console.log(response);
})

But something is not working.
"angular": "^1.5.8",

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Praud, 2017-03-21
@Praud

The thread can be closed. The file generation process will take place on the server, the client itself will not count it in any way. Using SignalR, I will monitor the download process and display it on the UI.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question