javascript - Unable to stop the downloading a file when the array is empty using ng-csv -


i have scenario want export array of json data csv file checking condition array empty or not. if array not empty getting file data. if empty want prevent downloading of file.i unable stop downloading of file.i using angular 1.5 components , angular material.

html:

   <md-menu-item>     <md-button ng-csv="$ctrl.csvprocess()" csv-header="["firstname","lastname","phonenumber","email"]" filename="details.csv">export selected</md-button> </md-menu-item> 

controller:

   csvprocess() {     if (this.memberselrows.length === 0) {         this.toastservice.show('please select member(s) export.', {             theme: 'warn'         });     } else {         var csvobject = {};         var csvarray = [];         angular.foreach(this.memberselrows, function(value, key) {             csvobject = {};             csvobject.firstname = value.firstname             csvobject.lastname = value.lastname             csvobject.phonenumber = value.phonenumber             csvobject.email = value.email             csvarray.push(csvobject)          })         return csvarray     } } 

here this.memberselrows array.if empty need show toast message , stop downloading of file. getting toast message , downloaded file empty data. want stop downloading. appreciated.


Comments

Popular posts from this blog

angular - Is it possible to get native element for formControl? -

unity3d - Rotate an object to face an opposite direction -

javascript - Why jQuery Select box change event is now working? -