title: I want to perform a rest api request on click of a button angular js
body: <p>I want to perform a rest api on click of a button and show a loading bar until the request is completed and show the result of request in a mddialog . I am new to this I dont know how to proceed.</p>
  
  <p>Any answers help would be appreciated.</p>
  
  <pre><code>$http({
      method: 'GET',
      url: url1
    }).then(function successCallback(response) {
      var confirm = $mdDialog.confirm()
        .title('Download as CSV')
        .textContent('You can download the csv by clicking below link')
        .ariaLabel('Download')
        .targetEvent(response.data.export_url)
        .ok('Download as CSV');
      $mdDialog.show(confirm);
      // this callback will be called asynchronously
      // when the response is available
    }, function errorCallback(response) {
      // called asynchronously if an error occurs
      // or server returns response with an error status.
    });
  </code></pre>