angular / router

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

Allow component reuse even without having a route relationship #243

Open brphelps opened 9 years ago

brphelps commented 9 years ago

It looks like the current mechanism for component reuse is having the reusability of components dictated by their parent / child relationships in the new router.

It would be really nice if there was a "less opinionated" way of reusing the components -- I see a planned usage of a "canReuse" function which could allow something like this to be opted into (although, it seems more like a single page app would either want it to globally be turned on or off, along with the use of the canReuse function to allow for exceptions to either case).

Is support for this planned?

btford commented 9 years ago

It's an interesting idea, and I think important for certain types of animations. In short, yes I'd like to be able to do this, but it's not yet a high priority.

brphelps commented 9 years ago

I think the thing that makes this higher priority for my team's use cases is that it creates a coupling between how we structure our routes and how our components visually behave -- i.e. if we have a common component with any stateful UI, repaints will cause flashing. Generally speaking, it's something we'd end up working around (or moving out of the component model, which seems even less desirable).

afitterling commented 9 years ago

Hello, I am not sure if I got the point. We're currently using Angular 2 Router, but need to prevent Angular Router from deactivating the controller of one component on route switch. So, I would like to ask, if we could reuse any component without having the router newly instantiating the component on route switch, rather to just have the old component as it was before switching to another one. Can that be achieved with the current code? What would be a nice workaround?