Hi everybody,
i'm reading a book about AngularJS and there is something i do not fully
understand.
it is explained that:
<body ng-app ng-init="name='World'">
<h1>Hello, {{name}}</h1>
<div ng-controller="HelloCtrl">
Say hello to: <input type="text" ng-model="name">
<h2>Hello, {{name}}!</h2>
</div>
</body>
will not change the <h1> content with content of input text.
I understand it well as it change the property NAME of the current scope.
However, they say that if you want to change the property of the parent
scope, it is a bad idea to use:
<input type="text" ng-model="$parent.name">
as if an intermediate element is inserted like a <div> it will not work.
Here again i understand, but what i do not catch is why they say that
following example is better to access to parent property scope:
<body ng-app ng-init="thing = {name : 'World'}">
<h1>Hello, {{thing.name}}</h1>
<div ng-controller="HelloCtrl">
Say hello to: <input type="text" ng-model="thing.name">
<h2>Hello, {{thing.name}}!</h2>
</div>
</body>
from my rookies eyes this is the same as the first snippet :(
so what is the point i'm missing ?
thanks a lot,
Al.
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.