-
Notifications
You must be signed in to change notification settings - Fork 27.4k
weird behavior with already resolved promises inside a digest in 1.4.1 with ngShow and ngAnimate #12143
Comments
Without a clean plunker that shows the error, it is not possible to even know if this is a bug or not. I will close this as without this, there is nothing to work on. If you can get a plunker in place that shows the error, then feel free to reopen this issue. |
Here's the plunkr. http://plnkr.co/edit/52OvOOunfY0fdLelyxWR The element sometimes has multiple values (null and undefined at the same time) when evaluated by the ng-show directives. Juste follow the insctrutions in the plunkr. It seems to be linked to angular-animate, since it works well without it. The issue is with ng-show, but not with ng-if. |
I can't reopen the issue myself btw. |
//cc: @matsko |
I wanted to +1 this. I've been struggling with a very similar scenario recently, though I haven't been able to reproduce it in a Plunkr. In both this case and my case, we a situation where ng-show gets itself into an invalid state where the expression passed to ng-show evaluates correctly ... but the ng-show does not update the element accordingly. This case: The expression evaluates to false, yes no
My case: The expression evaluates to true, yet the
In my case, it appears to be related to ngAnimate as well. If you trace the calls through the ngShow directive, everything looks fine, and it's not until here that things fall apart: angular.js/src/ngAnimate/animateQueue.js Line 231 in 291d7c4
In my case ... the watched value Anyway, not sure if this helps or not, if i can debug this any further or reproduce in a plunk I will leave some additional information. Note: I worked around this in the meantime by simply using |
Works fine in 1.4.x master: http://plnkr.co/edit/dsdJKzuoC4hNYHSNk7hg?p=preview |
I have stumbled upon a weird behavior when migrating to angular 1.4.
I'll try to create a plunkr example when/if I have the time later.
For the time being, here's the issue's description.
Here's a simple controller:
The controller watches an
id
, and updates anelt
when theid
changes.The
elt
is retrieved using a function that returns a $q promise.elt
is set tonull
to indicate the loading state.The function uses a cache of $q promises, so that it will return the already resolved promise if it is called with an
id
it already knows.When the function returns an already resolved promise, the digest seems to be in a strange state. The template still considers that the
elt
isnull
, although, when consulting the scope in the console,this.elt
is notnull
. Calling$rootScope.$digest()
doesn't change anything.This also happens when I return a new promise that's resolved when the intiial promise is resolved (next tick since it's already resolved).
This issue does not happen if I return a completely new promise, or if I wrap the function call inside a setTimeout.
The text was updated successfully, but these errors were encountered: