ng-csv icon indicating copy to clipboard operation
ng-csv copied to clipboard

Seems that some attributes are being ignored in 0.2.3

Open SimeonC opened this issue 10 years ago • 2 comments

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.

SimeonC avatar Sep 02 '14 23:09 SimeonC

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

asafdav avatar Sep 10 '14 11:09 asafdav

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!

leafsicle avatar Apr 18 '19 12:04 leafsicle