-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Views are rendered twice on route transition #881
Comments
any update on this? do you know if it was fixed in 0.2.10. im seeing the same problem now |
i tried this patch and it broke for me. what is "ui-view-anchor" referring to? do i need to add that tag somewhere in my template? |
I'll have a look at 0.2.10 when I'm back in office next week. |
thanks for reply. not a big deal now. i've given up on ui-router now... its just not ready for what we want to do (preserve dom cache/state between state changes). Im back to RouteProvider and ng:show which seems to work great now... |
Mhh interesting, seems we're running into the same issue you described. We're on version 0.2.8. Tried to update to 0.2.10 today and got an error, but don't know right now if it is related with this. Would be great to hear if there is a fix in version 0.2.10. The code in this version in viewDirective.js looks a lot different to 0.2.7 |
Should be fixed, as |
Alright, I've checked 0.2.10 - and the problem still persists. As I've mentioned in the report, the handling of uiView was already changed in 0.2.8 (the version I picked the code from), but it seems to just have moved the problem to another place. |
0.2.10 changed it again, and more extensively. Could you possibly create a minimal reproduction of the problem in a Plunkr? |
First of all, I've already mentioned that the hackfix I've illustrated for 0.2.7 did not work for later versions - seems the cause of this problem has changed since then. However, I've stripped down some of our logic and created a medium-complex example here (had to provide angular and ui-router manually, since Chrome complained about MIME types), but unfortunately, it does not illustrate the error. I'm not sure why, since it includes all logical steps we are using. Do you see anything that might cause a problem slightly misused in a wrong way? Maybe one of the others that have faced this are more lucky with a smaller example? Just to illustrate that this is not a joke: That was a test with 0.2.10 this morning, which created the feedController three (!) times, always with different ids (see the right hand side), before anything happens on the site (see the upper part). I'm sorry that I can't provide more details, but most of the projects contents are rather... secret up to now. |
Hi, seems like I'm also getting this (0.2.10). I didn't check other ui-views, but currently 4-th (nested in other ui-views: 4th inside 3rd, 3rd inside 2nd etc) ui-view is doing that. I'm loading a cached template markup into ui-view="workspaceEditorContent", each template has a controller set, so inside one of those controllers I've added an 'alert'. When that view is loaded I see previously loaded content AND the new one which is being loaded. Following image should help: For now fixed the UI glitch with: [ui-view="workspaceEditorContent"] : nth-child(2)
{
display:none;
} |
Have exactly issue as @snekbaev, 2 view and only 1 controller instantiation. v0.2.10 update: comment in viewDirective.js lines 143:157 (exclude $animate and $animator) - and it seems it solved the problem |
Is this a ui-router error or a ng-animate? |
Seems to be ui-router. Today i removed yeoman, grunt and all stuuf installed by yeoman. I made a fresh install of phonegap and angular and now all works well ... Really strange
|
Any update on this issue? I just had it start occurring. Am attempting some of the solutions here but was curious if this bug has been fixed since July. |
We've recently switched to 0.2.11 (using angular 1.3) and the issue seems to be solved. |
I'm still seeing this issue on 0.2.12, I would be surprised if this is actually fixed. @artem1 your workaround to comment out the $animate and $animator code does not work for me |
This error can happen when using ui-router, as ui-router will manage your application lifecycle incorrectly. See this issue for more information: angular-ui/ui-router#881
I am using 0.2.13 and this is still happening. |
@Ikhos What version of Angular? |
@nateabele I'm using 1.3.15. Since I am using multiple modules I am using angular.bootstrap().
This is the bootstraping config:
I just found out that if I comment the angular.bootstrap(...) line, the ui-view renders just once. Any hints on this behaviour will be greatly appreciated. |
I feel really dumb now. I was using ng-app="" as well as initialising the app programmatically. I just removed the ng-app directive from my view and everything works perfectly now. Thanks. |
👍 You might feel dumb for having wasted time on it, but those are the best kinds of problems to have. Seriously. |
I almost missed @edrpls 's answer, just because @nateabele 's bad joke. 😏 |
This occurs for me with the latest ui-router. I need to use ng-app="app" and angular.bootstrap because I have window.name = "NG_DEFER_BOOTSTRAP!"; .The app is only instantiated once, so why does this occur for me still? |
Hi there, How can I fix that? Where are the suspicious places that might make this issue? |
Hi there, I'm facing the same issue. Using Angular 1.4.9 and angular-ui-router 0.2.18. Do someone have any clue of what causes this ? |
Hi there, |
Why is this Closed? This happens to me as well when using Chartist.js (charting library). I'm bootstraping with This hack fixes it: $rootScope.$on('$stateChangeStart', () => {
$animate.enabled(false);
}); But I'd really like it to be resolved, especially if I'd want to add state change animations later on. Versions:
|
This is still a problem for me too. I'm using ng-animate along with ui-router to animate transitions. I started noticing that my view content was appearing twice on the screen during a transition, the bottom of the two look like styled empty templates while the one above is rendered properly. I'm using ng-app, not bootsrapping the app in js. After the animation is complete, the duplicated view disappears. This screenshot shows the duplicated ui-view during the transition. After which, it disappears. The user can see this duplication on the screen while the transition is active: These are my versions:
UPDATE: I just noticed that if I trigger my ui-view transition a bunch by rapid clicking, I can get up to 5 ui-views rendered on the page: UPDATE # 2 I finally realized that I had a directive that was dynamically adding a style to the same element that is serving as my |
For me the solution was to completely remove angular-animate. And it is extremely bad solution I know. |
It's also an issue for me. Is there any acceptable workaround yet? |
+1 |
Me too have this problem using the following versions: The code for this workaround is the following: |
+1 |
My team has recently faced an issue with controllers being instantiated twice on route transition. While trying to find the reason for this, I've recognized that even the corresponding views got rendered twice, which was rather... unlikely.
This problem was detected in v0.2.7 - 20fcbf8 thus I considered moving to v0.2.8 - f9ce4dd should solve this. But it did not.
Information
Angular-version: 1.2.11
The relevant routes look like this (I cannot post everything, since it's part of a closed project):
While using this template in 1ColumnLayout.html...
...and this one in 2ColumnLayout.html
In a more-or-less long debugging session, I was able to drag down the issue to the following line in viewDirective.js (in v0.2.7):
The call stack mentioned that by calling transclude(...), the compile function is called again, building up the entire view, including controller instantiation. Afterwards, the function went ahead as expected, but destroyed the previously built view completely, building it up once more.
In v0.2.8, this line of code has changed to
which seems more intuitive. However, moving to v0.2.8 did not fix the issue - seems to be broken on another part.
The curious thing...
... is primarily related to the sometimes in the topic: After performing all potential route transitions at least once, all views got rendered only once - as expected.
Workaround
Anyway, just for testing, I've changed
in v0.2.7 to
(picked from v0.2.8), and injected $document as well. Result: Everything worked as expected (I've added my diff so that the whole change is visible), which is... interesting.
Even worse, I was not able to reproduce this issue using v0.2.8 with a more simple example, and I'm not sure why it still occurs - wasn't that easy to drag down to a particular line as in v0.2.7 ;)
Maybe some of you have a clue what may cause this, or may check this in a more complex project - rendering views twice, including controller instantiation, is rather unlikely when it comes to performance, or possible side-effects that come along with init-functions.
For the moment, this appears to be a blocking issue in our case which prevents us from moving to v0.2.8 and, as a result, from other fixes / improvements.
The text was updated successfully, but these errors were encountered: