Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular 2: Swapping between different components without destroying them

Tags:

angular

I'm trying to build a window manager with Angular 2. Basically, I want to be able to swap between windows (that are components injected in a router outlet) without losing their states. For instance, I'm editing a product information form when I change to a customers' list, then I come back to the product form and I find it in the same state... Is it possible?

like image 619
cangosta Avatar asked Nov 11 '15 10:11

cangosta


1 Answers

Checkout canReuse on the router: canReuse in angular2 api docs

If you specify it the router wont destroy your component when switching away from it.

like image 199
Dennis Smolek Avatar answered Oct 08 '22 10:10

Dennis Smolek