javascript - Making async call dropboxjs -


i have problem when want read directories dropbox api, dropbox.js https://github.com/dropbox/dropbox-js

the read directories function the api looks , want assign value angular reach in html.

update after helpful question

client.readdir("/", function(error, entries, stat1, stat2) {             if (error) {                return showerror(error);             }              $scope.dbitems = stat1;                 $scope.$digest();         }); 

the html-code:

<ul ng-repeat="dbitem in dbitems">    <li><input type="image" src="img/folder.png">{{dbitem.name}}</input></li> </ul> 

my problem dropbox call takes milliseconds have reload page print data collected. i've tried things both angular , jquery promises can't work. examples find promises has settimeout-function , easy implement when try implement dropbox doesn't work. has tried similar?

update problem

now html updated correctly want join of dropbox directories exported json. i've updated function above like:

$scope.listdb = function()     {            client.readdir(dirtostring(), function(error, entries, stat1, stat2) {             if (error) {                 return showerror(error);  // went wrong.             }              $scope.dbitems = stat2;             $scope.$digest();             testtemp  = stat1._json;             setfolders(testtemp);             function setfolders(current)             {                 for(var i=0,folders = current.contents;i<folders.length;i++)                 {                     if(folders[i].is_dir)                     {                         folders[i].name = folders[i].path.replace(/\/([^)]+)\//,"");                         folders[i].name = folders[i].name.replace('/',"");                         $scope.listdbinner(folders[i].name);                         var inner = $scope.inneritems;                         folders[i].contents = inner;                         setfolders(folders[i]);                     }                 }             }         });     }; 

with listdbinner:

    $scope.listdbinner = function(name)         {                client.readdir(name, function(error, entries, stat1, stat2) {                 if (error) {                     return showerror(error);  // went wrong.                 }                 $scope.inneritems = stat1;                 $scope.$digest();                             console.log($scope.inneritems);             });             console.log($scope.inneritems);         }; 

the problem console.log of $scope.inneritems inside of client.readdir correct , 1 outside empty. know should solved promises of kind can't work.


Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -