2016-08-25 50 views
0

形成cordova.file.tempDirectory我们要读取的图像的名字形成cordova.file.tempDirectory使用我们试图这样如何读取图像名称中使用伍,科尔多瓦

$cordovaFile.readAsText(cordova.file.tempDirectory) 
      .then(function (success) { 
       console.log("success2"+success); 
        }, function (error) { 
         console.log("error"+error); 
        }); 
But We got error 


ERROR: Wrong type for parameter "path" of DirectoryEntry.getFile: Expected String, but got Undefined. 
2016-08-25 09:23:28.958 DPOD[3482:38292] Error in Success callbackId: File1548160221 : TypeError: Wrong type for parameter "path" of DirectoryEntry.getFile: Expected String, but got Undefined. 

cordova.file.tempDirectory文件的插件只有10 images.So我们需要10images name.tell我的代码有什么问题,请指导我们。

回答

0

$ cordova.readAsText接受两个参数路径文件

// READ 
$cordovaFile.readAsText(cordova.file.dataDirectory,$scope.inputs.readFile) 
    .then(function (success) { 
    // success 
    }, function (error) { 
    // error 
    }); 

尝试将文件读取为数组缓冲区。请参阅其他阅读文件的选项。 ngCordova file plugin

确保添加ngCordova文件和适当的依赖注入。 Installation guide