Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Extra digest required if Angular >= 1.1.4 #71
Same bug (unless it's an undocumented "feature") as $http/$resource.
I agree that this sucks, but Angular's best practices do recommend that when you're getting a callback from an "unknown" event to Angular, you should actually call $scope.$apply to perform a new digest cycle. If you do that, you wouldn't have this error, and if you're using Angular 1.0.7 you wouldn't have this error either when doing the $apply as it checks wether there's already a $$phase running.
So I think there's an easy solution for this. I do agree that this is not a "feature", but it does make sense to call the $apply after any callback that angular doesn't know about, don't you agree?
If they do change this in Angular >= 1.1.4, it'll work here as well. I could check for Angular's version with some hacky thing and call the $apply to perform an extra digest before your callback but I don't know if this makes sense to do it. What do you think?
Thanks for the report!
Well, to be honest I don't share this view. What I have believed was that you should $apply when you want to update bindings outside the Angular context. BUT in the case of $http and $resource you care about the bindings only when the data comes back from the server! (And in that case, both of them don't fail of course, regardless of when they were called). I find it incredibly weird that we need to call $apply just to get the request out to the server.
So the implications for Restangular? I don't have an easy answer, actually. I definitely don't think that the developer should call $apply to send a request to the server - there is no sense in that, and if $resource persists with this "feature"/"bug" then it would be great if you can do away with this for the rest of us, somehow. In either case, for all of $http, $resource, and Restangular none of this is documented behavior - so in my eyes it's a bug either way - of documentation or design/code.
So even if you just wanted to document it - I'm not sure what you should write, to be honest.
added a commit
May 28, 2013
Include lodash or underscore before
On Fri, Nov 1, 2013 at 12:58 AM, sujoy18 firstname.lastname@example.org wrote:
I've implemented something to fix this promise unwrapping problem.