ngCordova - 将数据写入文件

时间:2014-10-29 15:37:58

标签: angularjs ionic-framework cordova-plugins

我正在尝试弄清楚如何使用ngCordova

将数据写入文件

文档说明

$cordovaFile.writeFile(filePath).then(function(result) {
      // Success! 
  }, function(err) {
      // An error occured. Show a message to the user
  });

但我不知道你在哪里传递你想写的实际数据。例如,我如何将一些简单的JSON写入文件?

1 个答案:

答案 0 :(得分:0)

文档现在已更改,它是: -

$cordovaFile.writeFile(filePath, data, options).then(function(result) {
  // Success! 
}, function(err) {
  // An error occured. Show a message to the user
});

但是我能够让它仅适用于android。根据官方文档,iOS有一些权限问题: - https://github.com/apache/cordova-plugin-file/blob/master/doc/index.md#ios-quirks