简体   繁体   English

角度状态管理

[英]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.我已经阅读了 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我在状态管理中使用了 rxjs 并且能够实现它,但我认为这不是一个好方法。我想要更好的方法来做到这一点

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.您所谈论的是客户端状态,您通常会在其中保存过滤器选项和 UI 状态,例如应展开或关闭手风琴。 Also your URL should reflect the filter options, meaning the URL should contain the filer options and their values.此外,您的 URL 应反映过滤器选项,这意味着 URL 应包含过滤器选项及其值。 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.这适用于任何技术,而不仅仅是角度。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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