This repository has been archived by the owner on Sep 20, 2020. It is now read-only.
Move all module-level variables to the core provider. #222
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi Chris,
this should be a fun one for you :) I am developing a state-heavy app in angular, and of course I make heavy use of ui-router and ui-router-extras (thanks a lot for this!). However, I was missing a "view stack" (like a deck of cards) similar to the Onsen UI navigator. I hacked up my own version by bootstrapping one angular app for each "card" in the "deck" and only making the top app visible. This must happen outside angular, because angular apps can't be nested in the DOM tree, but apart from that cosmetic wart things fell into place nicely. Of course, I have to carefully manage the location to match the active app, but ui-router has all the necessary plunging for that.
What didn't work was ui-router-extra's sticky flag. The errors are difficult to describe: After pushing and popping a "card", the remaining cards got "out of sync" so to speak and lost their stickiness. After banging my head against my code for a while, I found out that ui-router-extra uses module-level state variables a lot. Ouch! This prevents multiple angular apps using ui-router-extra from running in parallel on a single website.
That's a real shame, because angular is so well modularized. So I moved the module-level variables to the core provider, and things work out fine for me now. However, I am ready to admit that I don't get all nuances of the provider initialization, and the way you access the run time instance of a provider in the functions defined in config() (which usually only has access to the provider factory!). However, a couple of $get invocations seemed to do the trick. Maybe that's a bit dirty, but not worse than before.
The other problem is that a test fails now:
I wish I could help you out with that, but frankly, there is an app to write and I don't need the future state feature. Maybe someone else wants to help clean this up, or maybe it's something easy for you to look at? Otherwise I might look at it later, but it would be weeks rather than days, so I wanted to get the patch out there right now. Happy hacking!
BTW, here is a test: Working Broken