This is problem.
$scope.count = 1; adds the count property to the area where <test> is located. Let me call it the parent area.
ng-transclude creates a new region, allowing it to be called its child region. When <h3>Inner {{count}}</h3> is evaluated, the child region does not have the count property, so it reads from the parent region.
<input type="text" ng-model="count"> binds the input value to the count property in the area of ββthe child objects. As soon as you enter something, the property will be created if it has not already been. From now on, on <h3>Inner {{count}}</h3> gets its value from the content area.
Areas in angular are simple JavaScript objects and are linked to their parents via prototypes. So before you enter something, the content area looks something like this:
{ prototype: { // = parent scope count: 1 } }
When you change the value to, say, 5, the scope is something like
{ count: 5, prototype: { // = parent scope count: 1 } }
Since data binding does something like scope.count = 5 .
zeroflagL
source share