ng-csv
ng-csv copied to clipboard
ng-csv doesn't work on dynamically created button
I was trying out ng-csv. And it worked fine for me.
But consider this scenario.
CASE 1
I have a button like this.
View(HTML) Code
where csvData and csvHeader are scope variables. I click the above tag and it exports the CSV. All good !!
CASE 2 But, consider the case where I dont have the csvData handy or ready. I need to dowload it from elsewhere: maybe an API call, or from the database.
So I changed my code to this,
View(HTML) Code
Now, when I click on it, it calls the getData() function, but doesn't wait for the data(or to set any scope variables), and downloads a 0byte CSV file.
So the thing is as soon as you click the html-tag(, ,