Progress bar Angular js

0

I use the $http of angular JS to work with web-services, does anyone know how to create a progressbar 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!");
       }
});

I wanted to use the bootstrap progress bar, but I can not find a method that does ajax and return the flush of the request.

    
asked by anonymous 10.10.2017 / 19:55

1 answer

0

Implement an interceptor . From original documentation :

  

Interceptors are service factories that are registered with the provider $http , via addition to the $httpProvider.interceptors array. The factory is called and injected with dependencies (if one is specified) and returns the interceptor.

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

This process works well if you just need to know if a call has ended or not.

To know what fraction your process is, you need to know the final size. In file uploads this is easy because HTTP headers indicate size. However in a custom process you need to generate this header, or an endpoint that reports the current state of processing.

Implementation Example (OS in English)

    
10.10.2017 / 20:40