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.
Any answers help would be appreciated.
$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.
});
Your click action
Controller
The loading bar
You just need to install this Angular loader and it will do the rest for you