I've got an angular app where I'm saving a file to pdf. What I want to happen is that when the user clicks the save button, the save button disappers while the file is being made, so that the user doesn't press the button multiple times.
What I have is
function toggleSavingPdf(){
return scope.savingPdf = !scope.savingPdf;
}
function saveToPdf(){
toggleSavingPdf();
var doc = new jsPDF();
scope.docs.forEach(function(img, idx){
if(img.src){
console.log('index of page', idx);
if(idx>0) doc.addPage();
doc.addImage(img.src,'png',0, 0, 210, 290);
}
if(idx===scope.docs.length-1){
console.log('change saving', scope.savingPdf);
toggleSavingPdf(); }
});
doc.save('Kiosk.pdf');
}
and in my template I have
<div id="document-list" ng-show="savingPdf">
but the document-list never hides, unless I change the ng-show to ng-hide, in which case it never shows.
I've tried running scope.$apply() after each toggleSavingPdf(), but it tells me an apply is already in progress.
This must be possible. It takes about 3+ seconds to create the pdf, so ample time for the user to hit the button multiple times.