$scope 和 $rootScope 的区别 [英] Difference between $scope and $rootScope

查看:38
本文介绍了$scope 和 $rootScope 的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谁能解释一下 $scope 和 $rootScope 之间的区别?

我觉得

$scope:

<块引用>

我们可以使用它从特定页面获取特定控制器中的 ng-model 属性.

<小时>

$rootScope

<块引用>

通过使用它,我们可以从任何页面获取任何控制器中的所有 ng-model 属性.

<小时>

这是正确的吗?或者其他什么?

解决方案

"$rootScope" 是在网页中创建的所有$scope" angular 对象的父对象.

$scope 是用 ng-controller 创建的,而 $rootscope 是用 ng-app 创建的.

Can anyone explain the difference between $scope and $rootScope?

I think

$scope:

We can get ng-model properties in particular controller from the particular page by using this.


$rootScope

We can get all ng-model properties in any controller from any page by using this.


Is this correct? Or anything else?

解决方案

"$rootScope" is a parent object of all "$scope" angular objects created in a web page.

$scope is created with ng-controller while $rootscope is created with ng-app.

这篇关于$scope 和 $rootScope 的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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