asafdav / ng-csv

Simple directive that turns arrays and objects into downloadable CSV files
MIT License
573 stars 215 forks source link

Seems that some attributes are being ignored in 0.2.3 #53

Open SimeonC opened 10 years ago

SimeonC commented 10 years ago

Using these attributes: ng-csv="csv.generate()" quote-strings="true" lazy-load="true" csv-header="csv.header()" filename="timesheet.csv" it seems that the csv-header and filename attributes are being ignored.

I think the issues are here: L41 return $scope.filename || 'download.csv'; The scope isn't getting the value, as you aren't actually watching the value it's probably better to use $attrs.filename instead of $scope.filename and I think they dropped the '@' scope declaration at some point in angular 1.2 which is probably why it isn't working for me.

The other issue is here: L49 if (angular.isDefined($attrs.csvHeader)) options.header = $scope.$eval($scope.header);. I think you meant to do $scope.$parent.$eval($scope.header) as your scope option in the directive is creating a child scope.

I've found that optional attributes are generally better off not putting on the scope option of the directive and just checking for their existence via $attr.

Thanks for the module, apart from those it's worked great for me.

asafdav commented 10 years ago

Hi, Sorry for my late response. Thank you for your elaborated description here, would you be able to post a plunker that I can play with ?

Thanks again

leafsicle commented 5 years ago

I'm not going to lie I was having serious issues with getting my double quotes but seeing this issue helped me fix my bug. Thank you!