search

Home  >  Q&A  >  body text

angular.js - AngularJs作为SPA应用该如何保存数据呢?

angularjs是单页应用,对于全局需要用到的数据可以使用services来实现共享,但是如果当用户刷新页面后,貌似一切都重新开始了,类似于开了新的生命周期,那样整个应用岂不是不健壮了么?
或者说是需要在本地localstorage中保存一份数据?请问该怎么解决

伊谢尔伦伊谢尔伦2745 days ago614

reply all(2)I'll reply

  • 習慣沉默

    習慣沉默2017-05-15 16:58:24

    The SPA I know will use local storage combined with server-side storage. Server-side storage can solve the restart problem you mentioned above. You can also allow users to log in and bind relevant data to the user. Of course, the specifics still depend on the needs of the project.

    reply
    0
  • 给我你的怀抱

    给我你的怀抱2017-05-15 16:58:24

    1 Isn’t it natural that the page should be refreshed after pressing F5? What if my SPA is refreshed? It does not change any user habits, and users will not feel confused.
    2 Instead, users should slowly develop the habit of not having to press F5 in SPA.
    3 I feel that what needs to be done is to save the user login status. This can be stored in the session of the server. It is the same as traditional web applications and has nothing special.

    reply
    0
  • Cancelreply