angularjs csv download to local

I made the service side to return csv format when I call the service with $http Get with Angular if the user click the button..

So the return is like 1,2,3,4,5,6,7,8,9,10

What is the best way to give the user the way to save it their local machine?

There are two options

1) Send the csv from your server.

2) Data URIs. I think this is what you're asking for. Here is an example

/**
 * @param{string} content The contents of a file to download.
 * @param{string} fileName The name to save the file as on the user's computer.
 */
function(content, fileName) {
  var dataUrl = 'data:text/csv;utf-9,' + encodeURI(content);
  var link = document.createElement('a');
  angular.element(link)
    .attr('href', dataUrl)
    .attr('download', fileName) // Pretty much only works in chrome
  link.click();
}

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]);