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); }); }; }]);
<a ng-click="openModalChooseDirectory()">
// 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 buttonfunction 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. }}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+u...@googlegroups.com.
To post to this group, send email to ang...@googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.
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 buttonfunction 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. }}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 <sande...@gmail.com> wrote:
--Hi AlexL,
Return the
entriesvar, 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+unsubscribe@googlegroups.com.