0

Just want to understand more about ng-scope inheritance/hierarchy, because i don't exactly understand how it works.

Assume i have a block like this

<div ng-controller="CtrlName">
<div ng-scope-1>
    <div ng-scope-2>
        <div ng-scope-3>
            <div ng-scope-4></div>
        </div>
    </div>
</div>

Is it correct to assume that from controller's point, to get to

  • Scope 1, i need to define $scope.scope1 in the controller
  • Scope 2, i need to define $scope.scope1.scope2 in the controller?
  • Scope 4, i need to define $scope.scope1.scope2.scope3.scope4 in the controller?

And what if scope 3 block is appended to scope 2 using ngInclude? Does the scope referring changes too?

I asked this because of this one question here - AngularJs: why doesn't ng-switch update when I use ng-click?

And the solution seems to mention about scope inheritance. Not sure if the example i gave above is related to the scope inheritance too.

Community
  • 1
  • 1
Fred A
  • 1,602
  • 1
  • 24
  • 41

0 Answers0