Skip to content
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

Infinite recursion when using $state.go( ) from a controller (in some scenarios) #1194

Closed
christopherthielen opened this issue Jul 8, 2014 · 3 comments
Labels

Comments

@christopherthielen
Copy link
Contributor

Test case and PR coming soon.

@christopherthielen
Copy link
Contributor Author

Incidentally, the fix for this does not seem to fix #1169

@christopherthielen
Copy link
Contributor Author

This bug is a regression from 0.2.10. It was caused by commit #7b78edee where $viewContentLoading events were allowed to be broadcast during $view.load.

$view.load fires the $viewContentLoading event. The event synchronously triggers an updateView. updateView doesn't know it's being re-entered and re-transcludes, which loads the template/controller. The controller calls state.go and the state is re-resolved. The fix involves setting latestLocals before loading the template and controller, so the next updateView early-exits.
screen shot 2014-07-08 at 7 36 00 pm

Also of note, '$uiViewName' is not used anywhere else. With the getUiViewName function, it's not necessary any more for this code. Theoretically, somebody else might be using it outside of UI-Router, but if not it could be simplified like so:

          if (!firstTime && previousLocals === latestLocals) return; // nothing to do
          latestLocals = $state.$current.locals[name];

          var clone = $transclude(newScope, function(clone) {
            renderer.enter(clone, $element, function onUiViewEnter() {
              if (angular.isDefined(autoScrollExp) && !autoScrollExp || scope.$eval(autoScrollExp)) {
                $uiViewScroll(clone);
              }
            });
            cleanupLastView();
          });

@christopherthielen
Copy link
Contributor Author

Possible dupe of #1040 . Also, I need to clean up a couple of things in the PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants