Csv export issues

Hi guys!

I am having troubles with csv export plugins, tried ngTableExport and ngCsv.
The former results in an “unsafe file” error on the device, the latter fails to instantiate the starter module.

Any hints?
Regards

Not really much of an ionic issue…

You could probably get more help with this issue on SO.

Having a similar problem. After including ionic.bundle.min.js in the project, .click() no longer seems to work to download data as a file.

var a = document.createElement(‘a’);
a.href = ‘data:attachment/csv,’ + csvString;
a.target = ‘_blank’;
a.download = ‘myFile.csv’;
document.body.appendChild(a);
a.click();

I’d actually say it is an ionic issue - the plugins work great until ionic is included. Here’s a relevant thread that includes plunkrs and steps to repro.

If anyone has hints on magic Ionic is doing re: file downloads, I’d love to hear them!

Alright, got a fix. The trouble is that ionic’s tap-handling code is eating the insert-link-and-click approach favored by most plugins.

The fix is to wrap the created link (not the plugin) in:

<div data-tap-disabled="true"> </div>

I’ve patched the ngCsv project, a similar fix should work for ngTableExport.

Not sure what ionic can do to make this simpler, but the tap-capture seems a bit greedy. Even when I didn’t put my ng-app on the body, it was capturing every tap/click - even those outside the angular app.

Hope this helps someone!