简体   繁体   中英

how to create a pop up on a download button click

i have a requirement in which on click of download button a zip file gets downloaded, now the download happens on the ui layer but the url is a API call (HANA) and it gets downloaded in the same page. Now, as there is no data, the zip file gets downloaded within very less time, but when in production scenario, the zip file would take some time to download. In this scenario, i need a pop-up such as "please wait... download in progress" so that the user doesn't get confused what is happening. I am using AngularJS

i have tried windows.location.assign() but i need a pop-up to display some text with ok or cancel button

this is my .html code

<button class="btn btn-primary" style="margin-right:10px;" ng-click="downloadData()">Download</button>

and my .js code

$scope.downloadData = function(){
    try{
        waitingDialog.show('Please wait!!!',{dialogSize: 'sm'});
        window.location.assign(Config.endpoints.getDownloadPreviewData.url);
        waitingDialog.hide();
    }
    catch(err){
        $scope.showAlert('Some problem occured during the download, kindly try after some time', $scope.closeAlert);
    }
}

If you want fancy popups you can use Ionic with Ionic Popups Ionic works great with AngularJS!

If you don't want to use Ionic you can use something like angular-bootstrap . They have some nice popups too!

If all else fails you may want to have a look at this .

Hope it helps!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM