使用Cordova导航本地目录

时间:2015-03-24 14:16:02

标签: javascript angularjs cordova

我正在尝试访问并浏览手机的本地目录,但我现在所做的就是列出根目录但无法遍历它...我对如何设置FileSystem.root感到困惑到选定的目录,以便我可以导航..

下面是我尝试过的列出列表

中所有目录的代码
//
var diary = angular.module('DiaryController', []);

diary.controller('MyCtrl', ['$scope', '$cordovaMedia', '$ionicPlatform', function($scope, $cordovaMedia, $ionicPlatform) {

//View File System Of Android
$ionicPlatform.ready(function () {
    window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, onFileSystemSuccess);
});

function onFileSystemSuccess (fileSystem) {
    console.log(fileSystem);
    var DirectoryEntry = fileSystem.root.createReader();
    DirectoryEntry.readEntries(onReadSuccess);
}

function onReadSuccess (entries) {
    console.log(entries);
    $scope.directories = [];

    for (i = 0; i < entries.length; i++) {
        $scope.directories.push(entries[i]);
    }

}


}]);

0 个答案:

没有答案