Wednesday 15 April 2015

javascript - Unblocking AngularJS UI -



javascript - Unblocking AngularJS UI -

i have angularjs app. app allows user come in number , press execute. when execute button pressed, dynamically building array processing. while array beingness built, ui seems lock. have following:

<input type="text" ng-model="numtoexecute"></input> <button class="btn btn-primary" ng-click="execute()">execute</button> <div class="alert alert-info" role="alert" ng-if="buildingarray === true"> <strong>building array</strong><br /> </div> $scope.preloadeditems = loadarray(); $scope.executetests = function() { $scope.buildingarray = true; var = 0; angular.foreach($scope.preloadeditems, function(item) { if (i < numtoexecute) { $scope.myarray.push({ id: item.id }); } = + 1; }); $scope.buildingarray = false; $scope.processarray(); };

the box says "building array" never appears. ui locks until angular.foreach statement done. preloadeditems array has thousands of entries in it. that's why want show "building array" box.

is there way unblock ui? or, @ to the lowest degree show building array box?

thanks!

put angular.foreach in $timeout

$timeout(function(){ angular.foreach($scope.preloadeditems, function(item) { if (i < numtoexecute) { $scope.myarray.push({ id: item.id }); } = + 1; }); },0)

javascript angularjs

No comments:

Post a Comment