After some test, it works good : angular.module('DirectoryBrowser', []) .controller('DirectoryBrowserCtrl', ['$scope', '$http', function ($scope, $http) { $scope.openModalChooseDirectory = function() { chrome.fileSystem.chooseEntry({type: 'openDirectory'}, function(theEntry) { if (!theEntry) { console.log('No Directory selected.'); return; } $scope.entryChoosen = theEntry; $scope.$apply(); // use local storage to retain access to this file loadDirEntry(theEntry, $scope); }); }; } ]) ;
// 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, $scope) { chosenEntry = _chosenEntry; if (chosenEntry.isDirectory) { var dirReader = chosenEntry.createReader(); var entries = []; // Call the reader.readEntries() until no more results are returned. var readEntries = function($scope) { console.log($scope); 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.push(item); }); $scope.entries = entries; $scope.$apply(); readEntries($scope); } }, errorHandler); }; readEntries($scope); // Start reading dirs. } } Thanks On Saturday, March 21, 2015 at 11:56:44 AM UTC+1, Alexandre LESAGE wrote: > > Hi Sander Elias, > > Sorry I have not thought about making plunker. > I would have like to return entries of loadDirEntry(theEntry) but in > openModalChooseDirectory $scope is undefined. How can I pass $scope into > function ? > > Thank for your help. > AlexL > > On Sat, Mar 21, 2015 at 8:21 AM Sander Elias <sanderel...@gmail.com> > wrote: > >> Hi AlexL, >> >> Return the entries var, and assign it to a scope var. >> Something like: scope.entries = loadDirEntry(theEntry). >> >> Does that help a bit. Building a plunk is a bit moot for this, as it only >> works in chrome apps ;) >> >> Regards >> Sander >> >> >> -- >> You received this message because you are subscribed to a topic in the >> Google Groups "AngularJS" group. >> To unsubscribe from this topic, visit >> https://groups.google.com/d/topic/angular/CPGWL1E35IY/unsubscribe. >> To unsubscribe from this group and all its topics, 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. >> > -- 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.