Closed rahul-desai3 closed 8 years ago
Hi,
You can define your html like this:
<div ng-csv="testDelim" csv-column-order="order" filename="custom.csv"></div>
In your JS file:
$scope.testDelim = [ {a:1, b:2, c:3}, {a:4, b:5, c:6} ]; $scope.order = [ 'b', 'a', 'c' ];
It output:
2,1,3 5,4,6
@shaohaolin It doesnt seem to work as expected. Here is the relevant part of my code:
HTML:
<button
class="btn btn-default"
ng-csv="csv.csvArray"
field-separator=","
decimal-separator="."
csv-column-order="order"
csv-header="['URL', 'TITLE', 'META DESCRIPTION']"
filename="{{ csv.filename }}.csv" >
<span class="glyphicon glyphicon-download-alt" aria-hidden="true"></span>
</button>
JS:
$scope.order = ['link', 'snippet', 'title'];
// all other variables have valid data
// I am running this on Angular.js v1.4.5
@shaohaolin I also tried it in jsFiddle and it wouldn't let me download the CSV. http://jsfiddle.net/HB7LU/18206/
@rahul-desai3 You forgot to DI.
angular .module('myApp',['ngSanitize', 'ngCsv'])
@shaohaolin I added that. It still didn't help :-|
@rahul-desai3 Something wrong when you import the ng-csv file. Please update the latest. Here is jsFiddle link that uses ng-csv cdnjs. http://jsfiddle.net/HB7LU/18208/
Updating it to the latest version works! Thanks @shaohaolin :)
@rahul-desai3 You are welcome! Enjoy hacking!
An example would be highly appreciated. (I didn't find it in your current examples.)
Thanks, Rahul