刷新了AngularJS守信范围变量 [英] Refreshing an AngularJS and keeping scope variables

查看:201
本文介绍了刷新了AngularJS守信范围变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能保持对范围变量刷新我的AngularJS页之后?我如何得到这个配置?

Is it possible to keep variables on scope after refreshing my AngularJS page? How do I get this configured?

谢谢!

推荐答案

有几个选项要做到这一点,

There are several options to do this,


  1. 对于较小的数据,你可以使用 $的CookieStore ,对于数据正在4K

  2. 另一种选择,尤其是对于大型数据集,将使用本地存储和然后检索页面加载/重新加载数据。

  3. ,如果它仅仅是一个非常小的数据量,或数据,它通过从多个页面中使用的可以使用$ rootscope,但这并不是因为它是最好的选择一样污染全局命名空间。

  4. 最后一个选项,这取决于检索数据的方式,一个服务可以实施,这是basiclly可以传递各种角度范围singlton。

  1. For smaller data you could use the $cookieStore, for data that is under 4k
  2. Another option, especially with large data sets, would be to use Local Storage and then retrieve the data on page load/reload.
  3. if it is only a very small amount of data, or data that is used through out multiple page you could use $rootscope, but this is not the best option as it just like polluting the global name space.
  4. The last option, depending on how the data is retrieved, a service could be implemented, that is basiclly a singlton that can be passed to various angular scope.

这一切都取决于您要在其中存储的数据。如果您提供您所要实现的目标则选项可能收窄什么更多的信息。

All of this is dependent on the data in which you want to store. If you provide more info on what you are trying to achieve then the options could be narrowed.

这篇关于刷新了AngularJS守信范围变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆