0

I need to display progress bar with percentages while document is generating. Document generating - POST request. I am trying to use this code

$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 it doesn't work for me. I don't even get into the progress function.
"angular": "^1.5.8".

Buh Buh
  • 7,443
  • 1
  • 34
  • 61
Praud
  • 297
  • 3
  • 13
  • what exactly do you mean request progress? – Pramod_Para Mar 21 '17 at 13:26
  • Replace `eventHandlers` by `uploadEventHandlers` – Weedoze Mar 21 '17 at 13:27
  • I mean I need to know the progress of the $http request and display it as a percentage. @Weedoze, I send a little data that needed for backed to generate documents. Just sending file extension and template. When I am using it shows me 100% Instantly, $http however request is not finished. – Praud Mar 21 '17 at 13:31
  • @БогданНосовицкий The code that you are working on is used to track the status of file uploads – Gangadhar Jannu Mar 21 '17 at 13:54
  • @Gangadhar Jannu , okay, and how should I track just post request status ? – Praud Mar 21 '17 at 14:08
  • @БогданНосовицкий You can't. See [this](http://stackoverflow.com/a/23206843/3543808) – Gangadhar Jannu Mar 21 '17 at 14:10
  • Okay. Clear. If server is generating file and the only way to calculate process until it finished is to calculate in on the server side and to send status via web sockets / SignalR. I will use the second because It's already in use. Thanks for answers, close this topic, please. – Praud Mar 21 '17 at 14:55

0 Answers0