31 lines
908 B
JavaScript
31 lines
908 B
JavaScript
|
/*
|
|||
|
Logic Solution
|
|||
|
WeeeCarbonFootprint
|
|||
|
Factory for CarbonFootprint
|
|||
|
*/
|
|||
|
|
|||
|
var arr = window.location.href.split("/");
|
|||
|
if (arr[3].indexOf('app') == 0)
|
|||
|
baseUrl = '';
|
|||
|
else
|
|||
|
baseUrl = '/' + arr[3];
|
|||
|
|
|||
|
angular.module('Services')
|
|||
|
.service('ExportCsvService', function ($q) {
|
|||
|
|
|||
|
this.startExport = function (data, fileName) {
|
|||
|
//console.log(data);
|
|||
|
var csvText = '\uFEFF' + Papa.unparse(data);
|
|||
|
require([baseUrl+'/Scripts/FileSaver.js'],
|
|||
|
function requrieSuccess(SaveAs) {
|
|||
|
var textFileAsBlob = new Blob([csvText], { type: 'text;charset=utf-8,' });
|
|||
|
saveAs(textFileAsBlob, fileName)
|
|||
|
},
|
|||
|
function requireError(error) {
|
|||
|
console.log('ExportCsvService: Require FileSaver.js failed:');
|
|||
|
console.log(error);
|
|||
|
}
|
|||
|
);
|
|||
|
}
|
|||
|
})
|