简体   繁体   中英

State management in angular

So I am stuck in state management in angular. lets say I have real estate web app user searches keywords and then applies few filters and then clicks on one result. Now when he presses back I want to give him back all the keywords, filters along with results as it is . I want to know which method and practices is best to achieve this. I have read about ngrx, rxjs. But I am bit confused in how to manage it on back press and all other stuff. I have used rxjs in state management and able to achieve it, but i don't think that was good way to do it.I want better way to do it

What you are talking about is the client state where you typically save filter options and UI states like if an accordion should be expanded or closed. Also your URL should reflect the filter options, meaning the URL should contain the filer options and their values. This way when user goes back the user is automatically taken to the page that shows the results for the same filter options applied before. This is true for any technology and not just angular.

过滤器不链接到应用程序状态,我认为更简单的方法是将它们保存在数据库中,或者保存在会话存储中。

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