清爽与控制器使用的页面时在控制器中使用$ rootscope值被覆盖 [英] $rootscope value used in a controller is overridden when refreshing the page used with that controller

查看:165
本文介绍了清爽与控制器使用的页面时在控制器中使用$ rootscope值被覆盖的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的angularjs页我使用angularjs的$ rootscope对象传递一个全球性的数据到另一个控制器。在我的控制器我是能够成功地捕捉存储在$ rootscope对象的值和值正确填充,我使用标签控逆变价值。但是,当我刷新页面的价值是越来越消失了。什么是这个问题,以及如何凸轮我克服这种情况。

In my angularjs page I am passing a global data to another controller using the $rootscope object of angularjs. In my controller i am successfully able to catch the value stored in $rootscope object and the value is populating correctly and i am using the value in a label contol. But when I am refreshing the page the value is getting disappeared . What is the problem in this and how cam I overcome this situation.

$ scope.loginname = $ rootScope.curusername;

$scope.loginname = $rootScope.curusername;

感谢和问候
Utpal

Thanks and regards Utpal

推荐答案

如果您重新加载页面,你在JavaScript中变量存储的所有信息丢失。 $ rootScope没有什么更多的则在JavaScript中的变量。如果你想存储的东西,仍然存在重新加载页面至少有以下几种可能:

If you reload your page all information that you store in JavaScript variables are lost. $rootScope is nothing more then a variable in JavaScript. If you want to store something that persists a page reload there are at least the following possibilities:

这篇关于清爽与控制器使用的页面时在控制器中使用$ rootscope值被覆盖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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