-
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
ui-state module and scoping #306
Comments
I'm working on some relative state targeting features that should allow child and sibling states to be navigated without knowing where you are in the hierarchy. Beyond that, I can't really think of what else you need to accomplish what you're talking about. Maybe you could start by putting together a small prototype, and if you can't get it to do what you want, throw it up on Plunkr and we'll take a look. |
Basically I'm trying to do something like this Here's a crude pseudo code plunkr that hopefully helps say what I want to do. I'm trying to use ui-state and ui-views with a scope other than global. You could then leverage all the view changing ability independently in a given component. I am new to Angular, so perhaps this a problem that has already been solved? |
Did that help at all? Is there any way to have two completely separate components in one Angular app with completely separate states at the same time? Or is this just simply not possible??? |
The wiki page and associated Plunkr example spell it out pretty explicitly. I'm not sure what you're trying to accomplish that can't already be done in a very straightforward way with what's been presented. |
it says "How do I configure ui-router from multiple modules, it doesn't seem to get the same state provider?" I want it to NOT have the same state provider. I want the left nav and the main view to be completely seperate, with their own state providers. Is that what that example is showing? Because it does not look like that to me at all. |
You don't need separate state providers for that. Again, I'm pretty sure the system is already capable of what you're asking for. I suggest you try it and see. Until then, I'll just leave this closed. If you try it and find that you are not able to do what you hope, please post a link to a live, working example, and reopen the issue, then we'll help you take a look at it. Thanks. |
I have been trying for the last 2 days. I get one $state object all over the application, it is scope to the root. When I change it, it changes state for everything. I don't want that. Think of a situation where I have 300 little modules in an angular app. Each one has a set of completely different states and views that have absolutely nothing to do with the others. Is that possible? Do you know what I'm asking? I'm not asking you to write it for me, I just want to know if it is possible. |
Sorry for the confusion. |
no problem, i appreciate your responses. I have read through a lot of the issues list, and the documentation many times, and stack over flow, google, etc. I just can't see how it can be done with the current code if state is only ever one global string -- short of registering every different possible combination of state between two components that have no real hierarchical relationship at all. -- eg how would you say "component 1, you go to state "yellow", and component 2, you go to state "green" without registering some yellowgreen state that sets up both the components. Even if I could just get a hold of one particular UI-View and control what template/controller combination goes in there, that would be something. I can't seem to get that figured out either because it's all tied up with rootscope. |
I'm sorry, I really don't quite follow, but I also really don't think that it's tied up with |
He wants to do orthogonal views. Not currently possible. MAYBE if you |
Yes. I have no desire to use URLS for anything but the one component. Everything else can get reset on refresh (or I could persist to local storage) Do you think if the ui.state and ui.view module were able to be used with a scope other than root, that would maybe do the trick? I will look into it, but being as I'm somewhat new, was looking for some guidance before I invest a lot of time. |
So yeah, I'm kinda new to this angular thing, but it seems to me there's some nice modular pieces here with ui-state, ui-view, ui-router. I want to know if there's any sort of (angular or otherwise) reason why they (seem) to be coupled with rootScope. Seems like it would be better to have the ability to pass in your own scope? Would it not be a potential shortcut to solving the independent state thing? I'm doing a POC to see if we even want to migrate our existing backbone.js app to this. I really want to use it, but reaching a major roadblock with this! Wish I had more domain knowledge to contribute instead of asking these abstract questions. |
@Broeks Haha, at least now I understand what it is you're after! :-) Thanks, @timkindberg. So, yeah, supporting multiple independent state trees for different scopes is definitely not something we support right now, unfortunately. However, this actually has very little to do with Then there are the conceptual problems with trying to manage multiple parallel states in a single global environment like a browser, especially when the whole point of the This leads us to all sorts of paradoxes, like 'which set of states gets serialized to the URL first?', and 'do we serialize the whole "first" tree from left to right before starting on the "second", whatever the second is?'... That being said, I'm not opposed to it, but given the project's current goals and technical constraints, I just don't see a way to do it. |
Well, i would think just carving out ui.state and ui.view to work in an independent state tree would be very useful for making DRY, stateful components/widgets. You could control those states from an application level using a "global" router, or by broadcasting events, or any number of other ways. Considering you've modularized them somewhat already, it didn't seem like too far of a stretch to provide an option to provide a local scope for those two pieces. Did you have a look at that RESTangular link i posted above? Is that a pattern that could possibly be used? (.withConfig) |
Or, at the very least, is there a way for me to grab a hold of a particular ui-view and manually set the template and controller? Independent of ui-state? That's what I've been looking into now... |
@Broeks We are not going to be able to look into this at the moment. We are trying to clean up and release 0.0.2 at the moment. If you figure anything out please share as I would be very interested if you can get something like that working. |
I'd like this feature as well, I think practically every large SAP will eventually run into a situation where they have multiple modules or controllers, that want to manage state of a particular widget, and do so independently- |
Almost. I've been working on extracting out a separate |
I think that would at least give us a way forward for the moment- |
Sounds great. Thank ya kindly. Hopefully we decide to go with angular here and I can contribute somehow. |
@mattbroekhuis, did you ever find a (temporary) solution to this? I'm trying to accomplish orthogonal views myself. I was considering some kind of custom URL .rule() that would break down a url (e.g. #/state/viewA1/viewA2/#/viewB1) to set the state and then somehow pass the views into the $rootScope to set the other views. This would be a one-way solution though (URL -> views), and would require one to write a whole new url with every single view changed. |
@mattbroekhuis @nateabele is there a temporarily solution for this? ui-router is great to manage url routes, but if my application has multiple components, having a $state for each component where I don't care about the URL would make development a lot easier. Right now I am sending messages through rootScope which is ugly. |
In my experimentation and reading the code, it seems as though ui-state is directly coupled with the $rootScope.
I would like to have seperate $uiState instances in two different controller scopes. This way, a component can manage it's subviews independently.
Am I right about this coupling? Or is there a way to accomplish this with the current codebase?
The text was updated successfully, but these errors were encountered: