Progress bar Angular js

Asked

Viewed 310 times

0

Use the $http from Angular JS to work with web-services, someone knows how to tell me how to create a progressibar using this method?

$http.get( "json.php?action=3"
      + "&id=" + id
      + "&val=" + $("#v"+id).val()
      + "&ajax_select_tab=" + ajax_select_tab
      + "&ajax_where=" + ajax_where ).then(function (result) {

      if (result.status === 200) {

          var chave = rows_.indexOf(ajax_select_tab[1]);
          $scope
              .rows[chave]["array_selec_data"] = result.data;
       } else {
            alert("Erro ao carregar o arquivo JSON!");
       }
});

wanted to use the bootstrap bar, but I can’t get a way to ajax and flush the request.

  • You want it to show an X% progress or just those "Loading" where there is no tracking of how much has been processed?

  • I need the percentage to popular the pub

  • I believe that the way your request is structured this will not be possible, because there is no control of what is being processed on the server, for that Voce would have to have push notifications passing the state of what is running on the server side... What could be done is put that "processing bar"

1 answer

0

Implement a Interceptor. Of original documentation:

The interceptors sane service Factories registered with the provider $http, via addition to the array $httpProvider.interceptors. To Factory is called and injected with dependencies (if any is specified) and returns the initiator.

Basically you can use interceptors for various global tasks involving the provider $http - for example authentication, or load generation spinners independent of endpoint called.

This process works fine if you just need to know if a call is over or not.

To know what fraction your process is to know the final size. In file uploads/receiving this is easy because HTTP headers indicate the size. However in a custom process you need to generate this header, or a endpoint reporting the current processing status.

Example of Implementation (OS).

Browser other questions tagged

You are not signed in. Login or sign up in order to post.