好的,因此keyResource從我的C#控制器中提取數據作爲逗號分隔值列表。當按鈕被點擊時,控制檯會記錄這些數據,但是當我將alasql查詢設置爲keyResource或數據時,它表示數據源0未定義。Alasql如何將數據導出到csv
angular.module("umbraco")
.controller("ExportAllController", function($scope, $http, keyResource){
$scope.exportAll = function ($scope) {
keyResource.exportAll().then(function (data) {
console.log(data);
alasql('SELECT * INTO CSV("AllDictionaryItems.csv",{headers:true}) FROM ?', []);
});
};
});
這是我目前有^
這些是我曾嘗試:
angular.module("umbraco")
.controller("ExportAllController", function($scope, $http, keyResource){
$scope.exportAll = function ($scope) {
keyResource.exportAll().then(function (data) {
console.log(data);
alasql('SELECT * INTO CSV("AllDictionaryItems.csv",{headers:true}) FROM ?', [$scope.exportAll]);
});
};
});
angular.module("umbraco")
.controller("ExportAllController", function($scope, $http, keyResource){
$scope.exportAll = function ($scope) {
keyResource.exportAll().then(function (data) {
console.log(data);
alasql('SELECT * INTO CSV("AllDictionaryItems.csv",{headers:true}) FROM ?', [keyResource]);
});
};
});
angular.module("umbraco")
.controller("ExportAllController", function($scope, $http, keyResource){
$scope.exportAll = function ($scope) {
keyResource.exportAll().then(function (data) {
console.log(data);
alasql('SELECT * INTO CSV("AllDictionaryItems.csv",{headers:true}) FROM ?', [data]);
});
};
});
我不知道如何做到這一點,因爲在中控臺記錄數據,我不知道爲什麼當我導出到CSV時它不工作?
什麼數據結構是你的'data'?即它在登錄到控制檯時看起來像什麼 –
它是控制檯 –