1

We are using the component router in an angular 1.5 webapp and require certain "landing" views (navigated to via main nav) to maintain state when you navigate away and then come back. Basically the view and component need to be hidden and then re-displayed when they come back.

This is something we've done before using ui-router and ui-router-extras. The latter has a concept of a sticky state (http://christopherthielen.github.io/ui-router-extras/#/sticky) which was very useful. I've read thru the angular 1.x and 2.x docs for the component router and cannot find any mention of a feature to cache views/components in a similar way.

Is this possible with the new component router?

flyer
  • 1,414
  • 12
  • 13
  • I think this is how angular 2 might handle this use case, by having your class implement canReuse: "Defines route lifecycle method routerCanReuse, which is called by the router to determine whether a component should be reused across routes, or whether to destroy and instantiate a new component." source: https://angular.io/docs/js/latest/api/router/CanReuse-interface.html Not positive b/c I haven't played with A2 yet. Can anyone confirm this? I do see this in the 1.5.1 router code: exports.routerCanReuse = CONST_EXPR(new RouteLifecycleHook("routerCanReuse")); – flyer Mar 10 '16 at 13:40

0 Answers0