ng-csv
ng-csv copied to clipboard
feat(skip-empty) added new option to skip downloading empty CSV
Found an issue when using ng-csv to export a file in conjunction with some validation. I was finding that the ng-csv would still trigger the download, even when the validation rules were failing (meaning underlying data was empty)
The behaviour I was seeking was to prevent the download in this case.
This PR provides the behaviour by adding a new attribute "skip-empty" (default false). When the directive is set, the CSV file will only be delivered to the browser when there is actual content.
I was checking on this too. A new attribute is a good idea. But instead of checking content in doClick(), I prefer to do it at stringify function by checking arrData length. This will avoid header only situation.