简体   繁体   中英

How to dont destroy showing tabs components in angular?

我的问题

Hello how can i dont destroy tabs components showing in image.

i will make a tab-like system.but for performance issues i want to destroy if i dont use tabs.

If i use tabs, dont destroy when i change.Because i want to use again models(like textbox) back to before tab.

i did now with router-outlet system but when i change tab, tab destroy itself.

any solution??

I think you should consider not storing or calculating anything in your components, because they are destroyed when you leave the route, and they should be destroyed. You don't want all your components to exist in parallel.

If you need to share some data between tabs (components), or just store state of the tab, you can do it with injectable services. Services are singletons by default, and you can inject the same instance every time router create tab content for you

Useful link: https://angular.io/guide/dependency-injection

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM