Hello,

I would like to display locals directories and files with chrome.System and 
angular.

So I have a controller :
angular.module('DirectoryBrowser', [])
  .controller('DirectoryBrowserCtrl', ['$scope', '$http',
    function ($scope, $http) {
      $scope.openModalChooseDirectory = function($scope) {
        chrome.fileSystem.chooseEntry({type: 'openDirectory'}, 
function(theEntry) {
          if (!theEntry) {
            output.textContent = 'No Directory selected.';
            return;
          }
          // use local storage to retain access to this file
          chrome.storage.local.set({'chosenFile': 
chrome.fileSystem.retainEntry(theEntry)});
          loadDirEntry(theEntry);
        });
      };
  }])
;


and this html : 
<a ng-click="openModalChooseDirectory()">

Si when a click on the link, a modal appear and let the user choose a local 
directory.

The function loadDirEntry is like that :
// for directories, read the contents of the top-level directory (ignore 
sub-dirs)
// and put the results into the textarea, then disable the Save As button
function loadDirEntry(_chosenEntry) {
  chosenEntry = _chosenEntry;
  if (chosenEntry.isDirectory) {
    var dirReader = chosenEntry.createReader();
    var entries = [];

    // Call the reader.readEntries() until no more results are returned.
    var readEntries = function() {
        dirReader.readEntries (function(results) {
        if (!results.length) {
          textarea.value = entries.join("\n");
          saveFileButton.disabled = true; // don't allow saving of the list
          displayEntryData(chosenEntry);
        }
        else {
          results.forEach(function(item) {
            entries = entries.concat(item.fullPath);
          });
          console.log(entries);
          readEntries();
        }
      }, errorHandler);
    };

    readEntries(); // Start reading dirs.
  }
}

the console.log contains all absolute path of directories in directory 
selected. So what I want...

First, I would like to populate $scope.directory with entries in order to 
display directories in my html. Have you any idea about how can I put 
entries in $scope.directory ?

The code I took about chrome.fileSystem provide from this project 
: 
https://github.com/GoogleChrome/chrome-app-samples/blob/master/samples/filesystem-access/js/app.js

Thanks,
AlexL

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to angular+unsubscr...@googlegroups.com.
To post to this group, send email to angular@googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to