Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(skip-empty) added new option to skip downloading empty CSV #131

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

nacmacfeegle
Copy link

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.

@chenchenick
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants