本文介绍了Rootscope没有工作角度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
请帮我解决下面的问题。
我已声明&在rootscope中分配一个值valrible&想要从另一个控制器访问,但它说在控制器2中取消定义。
控制器1
Hello All,
Please help me on bellow issue.
I have declare & assign a value in rootscope valrible & want to acces from another controller but it say undefine in controller 2.
Controller 1
$rootScope.name = 'anonymous';
controller2
controller2
$scope.local = $rootScope.name;
alert($scope.local);
但显示未定义,我是否缺少任何配置?
我尝试过:
But showing undefined, am i missing any configuration?
What I have tried:
Controller 1
<pre> $rootScope.name = 'anonymous';
controller2
controller2
$scope.local = $rootScope.name;
alert($scope.local);
推荐答案
controller2
controller2
这篇关于Rootscope没有工作角度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!