刷新页面时 AngularJS 数据丢失

标签 angularjs

这个问题在这里已经有了答案:





retain angular variables after page refresh

(5 个回答)


5年前关闭。




每次刷新页面时,AngularJS 变量中的数据都会丢失。如何在不使用 cookie 的情况下保留它们?任何人都可以帮助我提供一种方法吗?它不同于previous question因为我对不使用 cookie 的解决方案感兴趣。

最佳答案

对于小于 4k 的数据量,您可以使用 $cookieStore。
如果不止于此,您将需要查看 HTML5 localStorage

For more details please go through this post you will find different options of storage with comparison http://www.html5rocks.com/en/tutorials/offline/storage/

关于刷新页面时 AngularJS 数据丢失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35569807/

相关文章:

javascript - Angular rzslider : max value for min & min value for max; range slider

javascript - 如何在 angularjs 中的两个单独的 Controller 中运行函数

javascript - 访问父范围的 Controller 层次结构异常 : AngularJS

ajax - 调用 angularJS $http.jsonp 时未捕获的语法错误 : Unexpected token <,

twitter-bootstrap - "ratchet"和 "angular.js"配合得很好吗?

javascript - 使用 Angular 更新 jQuery 选择的选定值

json - 获取没有时间/时区的 ui.bootstrap.datepicker 值

javascript - 如何在单循环中过滤和分组 AngularJS 中的产品

angularjs - 如何在 ng-repeat 中分隔组

javascript - Angular 上的分离函数