how to export csv file in angularjs

JavaScript
alasql("SELECT * INTO CSV('mydata.csv', {headers:true}) FROM ?",[$scope.mydata]);
Source

Also in JavaScript: