-
Notifications
You must be signed in to change notification settings - Fork 216
Using CSV as Service
davorpeic edited this page Jun 17, 2014
·
2 revisions
If you need to use "ng-csv" in your controller, you can easily inject CSV service, and just make a call sending your data and options into the service. Then Service return the base64 encoded CSV file.
myapp.controller('MyCtrl', function($scope, CSV){
$scope.getArray = [{a: 1, b:2}, {a:3, b:4}];
$scope.options = {};
$scope.options.header = ['Field A', 'Field B'];
$scope.click_button = function() {
CSV.stringify($scope.getArray, $scope.options).then(function(result){
console.log(result);
});
}
}