You can try Alasql library, which can save data in CSV format one line:
function myCtrl($scope) {
$scope.filename = "mydata.csv";
$scope.cities = [{city:"Odessa",population:100000},
{city:"Voronezh",population:201022},
{city: "Paris", population: 3000000}];
$scope.saveCSV = function(filename, content) {
alasql('SELECT city, population INTO CSV("'+$scope.filename+'",{headers:true}) FROM ?',
[$scope.cities]);
};
};
See the full example code in jsFiddle.
In this example Alasql use SELECT operator to choose required fields from data array (AngularJS' creates $$hashKey field, which probably is not needed to users). If you do not use
on these data simply export to CSV file with:
alasql('SELECT * INTO CSV('mydata.csv') FROM ?',[$scope.data]);