Is there a way the stop the file download if the array is blank?
Opened this issue · 3 comments
ShaneQuinn commented
Can there be a switch added to not initiate a download if the array comes back empty?
Or is there a way to call this from a controller so the download call can be initiated after the presence of data can be verified?
pittmaca commented
This, or the ability to short circuit the click event would be a great feature
AguilaneP commented
check for $scope.data(); is undefined in the function $scope.buildCSV in ng-Csv.js
Here is the example:
/**
* Creates the CSV and updates the scope
* @returns {*}
*/
$scope.buildCSV = function () {
var deferred = $q.defer();
$element.addClass($attrs.ngCsvLoadingClass || 'ng-csv-loading');
var objectData = $scope.data();
if (objectData) {
CSV.stringify(objectData, getBuildCsvOptions()).then(function (csv) {
$scope.csv = csv;
$element.removeClass($attrs.ngCsvLoadingClass || 'ng-csv-loading');
deferred.resolve(csv);
});
}
$scope.$apply(); // Old angular support
return deferred.promise;
};
monokurobo commented
hi. @AguilaneP , I tried many ways to impl in controller, but failed. Could you help informing how to check in controller?