如何使用 electron-json-storage 将 json 发送回 angular
How to send json back to angular using electron-json-storage
我在 Electron 应用程序中使用 electron-json-storage to read/write json files and ngElectron。 electron-json-storage 的指南是这样写的:
storage.get('foobar', function(error, data) {
if (error) throw error;
console.log(data);
});
当使用 ngElectron 从 angular 调用该函数时,它在控制台中打印正常,但我怎样才能让对象将它存储在一个范围内并在以后使用它?
所以我知道怎么做了
在电子部分我必须return一个承诺
var deferred = q.defer();
storage.get('local Storage', function (error, data) {
if (error) {
throw error;
deferred.reject({'status': 500, 'result': {}, 'error': error});
}
deferred.resolve({'status': 200, 'result': data});
});
return deferred.promise;
在angular部分
ls.get('local Storage').then(function (data) {
console.log(data);
}).catch(function (error) {
console.error(error);
});
我在 Electron 应用程序中使用 electron-json-storage to read/write json files and ngElectron。 electron-json-storage 的指南是这样写的:
storage.get('foobar', function(error, data) {
if (error) throw error;
console.log(data);
});
当使用 ngElectron 从 angular 调用该函数时,它在控制台中打印正常,但我怎样才能让对象将它存储在一个范围内并在以后使用它?
所以我知道怎么做了
在电子部分我必须return一个承诺
var deferred = q.defer();
storage.get('local Storage', function (error, data) {
if (error) {
throw error;
deferred.reject({'status': 500, 'result': {}, 'error': error});
}
deferred.resolve({'status': 200, 'result': data});
});
return deferred.promise;
在angular部分
ls.get('local Storage').then(function (data) {
console.log(data);
}).catch(function (error) {
console.error(error);
});