我想点击按钮执行休息api并显示加载栏,直到请求完成并在mddialog中显示请求结果。我是新手,我不知道如何继续。
任何答案都会有所帮助。
$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.
});
答案 0 :(得分:2)
您的点击操作
<input type="button" ng-click="performCall()" />
<强>控制器强>
$scope.performCall = function(){
// Simple GET request example:
$http({
method: 'GET',
url: '/someUrl'
}).then(function successCallback(response) {
// 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.
});
}
加载栏
您只需要安装它 Angular loader它将为您完成其余的工作