angular / router

The Angular 1 Component Router
MIT License
665 stars 135 forks source link

Does the new router support multiple 'active' views that are not in a visible view port? #158

Open oneillci opened 9 years ago

oneillci commented 9 years ago

I have a question regarding the router and/or the page lifecycle.

I have a current Silverlight application that has multiple top level modules (think tabs). Each module contains it's own region and consists of a large set of business screens (30+ screens per module). Each module has a landing page with a menu as an entry point to the screens for that module.

Using these module regions we can have multiple 'active' views in the app at any one time, as switching between modules doesn't actually close an open form. Navigating back to any form presents the data in the same state it was left in. This allows me to navigate away from an open, dirty form with data in a potentially invalid state to another module without triggering a dirty validation message. Navigating back to the original module presents whichever view was most recently active in the state it was last left in.

Is multiple active pages (on different routes) a scenario can be handled with the current router or page life cycle implementation? Maybe I would need some method of persisting the current state of a viewmodel for a screen that perhaps falls outside the traditional activate and deactivate events?

Perhaps there could be additional hooks into the lifecycle that listen to navigation events and respond differently to different to different navigation types: modifying URL manually triggers dirty check, clicking in-app back button triggers dirty check, changing module does not etc.)

The attached images approximate what I'm attempting to say. http://myapp/module1/view-1 is in a dirty state, but I can still navigate to module 2 and create/destroy any of the views in module 2. Navigating back to module 1 shows view-1 in the dirty state it was left in.

This is a feature that will be supported by the Aurelia router AFAIK, and I think it would add real value for large apps.

mod1-home mod-1-view-1 mod-2-home mod-2-view-2

oneillci commented 9 years ago

I forgot to add: in my scenario, although the application will have a lot of views, there will only be one active view per module. Each view would be made of several components though

hrajchert commented 9 years ago

+1, something like the sticky concept on ui-router-extras http://christopherthielen.github.io/ui-router-extras/example/sticky/index.html#/inv/stores

Or ionic navigation http://ionicframework.com/docs/api/directive/ionNavView/

antch commented 9 years ago

+1 for this use-case. I asked about this during the Q&A at ng-conf.

mark-mccullough commented 9 years ago

+1, we'll need this if we're ever going to migrate to the new router.

Simon-Li commented 9 years ago

+1 for this use case.

ruifang commented 9 years ago

+1

rudzikdawid commented 8 years ago

+1

balmychan commented 8 years ago

+1

sicollins commented 8 years ago

+1