$scope.$apply() cant solve all problems...help


#1

I am getting data from Parse.com to my app, and using ng-repeat. However data is not always shown in the app after data is received(this does not happen in browser though). I tried using $scope.$apply() at the end of the async data retrieval function, this solved part of the problem as for most of the time it does show the data, but sometimes once in a while the data is still not shown…

Is there a better way of using $scope.$apply() or other alternatives to fully solve the problem?


#2

scope.$apply is a really bad idea for that. You should use this if something happens outside of the angularjs context. but if you are sending request with $http-service or another angularjs service you are not outside of that context. You can destroy your app with that.

You should use $timeout to hang in the next digest-cycle of angulars refreshing process.

But with a little bit more code, we could give you a better hint…
Like working with Promises to handle async stuff.