Can anyone explain the difference between $scope and $rootScope?
I think
We can get ng-model properties in particular cont
In other way we can look at this; $rootScope
is global while $scope
is local. When Controller
is assigned to a page, so a $scope
variable can be use here because it binds to this controller. But when we want to share its value across to other controllers or services, then $rootScope
is being used (**there are alternative ways, we can share values across but in this case we want to use $rootScope
).
Your second question about how you define those two words are correct.
Lastly a bit off track, please use $rootScope
with care. Similar to the way you use global variables, can be a pain to debug and you may accidentally change the global variable somewhere inside a timer or something which makes your reading incorrect.