Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-cloud-platform/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 要在中显示数据,请以ionic、angularjs读取文件txt_Javascript_Angularjs_Ionic Framework - Fatal编程技术网

Javascript 要在中显示数据,请以ionic、angularjs读取文件txt

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

对不起,我的英语不好。我是phonegap的新手,我试图读取一个文件并显示数据,但文件系统中有一个问题。 window.requestFileSystem不会调用fail方法。 我的全部代码是:

$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解决了这个问题。在所有功能中。谢谢你的帮助-