AngularJS: changing parent scope in ng-include

I found this thread in which the OP is the original script , where the region ng-included does not change the parent region.

One answer suggests:

This is ugly and unpredictable, so I recommend that you wrap your data in an object variable: http://jsfiddle.net/e5rfP/3/

which seems to work. Why is this?

+5
source share
2 answers

An object variable works because of how prototype JavaScript inheritance works. ngInclude creates its own child region. This child region is prototypically inherited from the parent region.

JavaScript, - $scope.x = 22 , x child $ 22 - , $scope , .

- $scope.someObj.prop1 = 22 , JavaScript someObj child $, , $scope $. someObj $scope, .

, SO ( ): / AngularJS?

+8

. , .

Repo, .

S.O. : -)

0

All Articles