Javascript 要在中显示数据,请以ionic、angularjs读取文件txt
对不起,我的英语不好。我是phonegap的新手,我试图读取一个文件并显示数据,但文件系统中有一个问题。 window.requestFileSystem不会调用fail方法。 我的全部代码是:Javascript 要在中显示数据,请以ionic、angularjs读取文件txt,javascript,angularjs,ionic-framework,Javascript,Angularjs,Ionic Framework,对不起,我的英语不好。我是phonegap的新手,我试图读取一个文件并显示数据,但文件系统中有一个问题。 window.requestFileSystem不会调用fail方法。 我的全部代码是: $scope.fail=function(){ alert("fallo"); } $scope.gotFS = function(fileSystem) { fileSystem.root.getFile('QReminderStyle/tema.txt', 0, gotFileEntry
$scope.fail=function(){
alert("fallo");
}
$scope.gotFS = function(fileSystem) {
fileSystem.root.getFile('QReminderStyle/tema.txt', 0, gotFileEntry, fail);
}
$scope.gotFileEntry = function(fileEntry) {
fileEntry.file(gotFile, fail);
}
$scope.abrirArchivo=function(){
$ionicPlatform.ready(function() {
window.requestFileSystem = window.requestFileSystem || window.webkitRequestFileSystem;
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFS, fail);
}
)}
$scope.gotFile=function(file){
readAsText(file);
}
$scope.readAsText = function(file) {
var reader = new FileReader();
reader.onloadend = function(e) {
alert("Read as text");
alert(JSON.stringify(e));
};
reader.readAsText(file);
}
我无法记录日志,因为我正在真实的设备中运行
谢谢你的帮助。应该是$scope.fail而不是fail吗?嗨,Leo,谢谢你的评论,我用$scope.fail修改,错误是一样的。那么,你得到了一个错误。。。错误是什么?不继续执行,也不调用fail方法。我用$scope解决了这个问题。在所有功能中。谢谢你的帮助-