ergo / polymer-ui-router

UI-router wrapper for Web Components
Apache License 2.0
22 stars 6 forks source link

Query, code structure for nested Routes #5

Closed vidhill closed 6 years ago

vidhill commented 6 years ago

Hello again,

I'm playing around with the router, verifying it will work for all my use cases

I created a little repo to show what I'm trying to do.. https://github.com/vidhill/polymer-ui-router-poc And a live githube pages version here: https://vidhill.github.io/polymer-ui-router-poc/build/default/index.html

I am using a subroute..

What I was hoping to be able to do was register the states for the subroutes somewhere besides the root application...

I have it working, to a degree, I have subroutes under #/dogs/

However, on first load, if I go to #/dogs/terrier it redirects back to the default (cats_route) state defined using otherwise

-because, as at that point the states that reside under dogs.html haven't been registered yet..


Is there a better way to do what I am trying to achieve? Or would I be better to go with the approach of managing all states from one location?

Many Thanks.

vidhill commented 6 years ago

I think I could define the additional states in a Behavior,

It appears that I should be able to get access to the router using UIRouterBehavior but I'm not quite sure how to bring it all together..

ergo commented 6 years ago

I would use behavior for that, since you need to update global state somewhere before your elements are getting added in many scenarios.

ergo commented 6 years ago

Closing, feel free to reopen if you need help.