Closed n8yeung closed 5 years ago
Hi I did some research, I think wrapping the $apply call would be better in a $timeout?
See:
http://stackoverflow.com/questions/23070822/angular-scope-apply-vs-timeout-as-a-safe-apply http://stackoverflow.com/questions/12729122/angularjs-prevent-error-digest-already-in-progress-when-calling-scope-apply (not the answer post:, best after)
autocompleteService.getPlacePredictions(request, function(predictions, status) { $timeout(function() { $scope.$apply(function() { var customPlacePredictions; clearPredictions(); if ($scope.customPlaces) { customPlacePredictions = getCustomPlacePredictions($scope.query); $scope.predictions.push.apply($scope.predictions, customPlacePredictions); } if (status == google.maps.places.PlacesServiceStatus.OK) { $scope.predictions.push.apply($scope.predictions, predictions); } if ($scope.predictions.length > 5) { $scope.predictions.length = 5; // trim predictions down to size } }); }); });
@kuhnza What do you think?
Hi I did some research, I think wrapping the $apply call would be better in a $timeout?
See:
http://stackoverflow.com/questions/23070822/angular-scope-apply-vs-timeout-as-a-safe-apply http://stackoverflow.com/questions/12729122/angularjs-prevent-error-digest-already-in-progress-when-calling-scope-apply (not the answer post:, best after)