Does my ng-model really need to have a dot to avoid child $scope problems?

A lot of things introduce new scopes. Let's say that in your controllers, you actually want to add tabs : first tab is actual rendering, second tab is the form (so that you have a real-time preview).

You decide to use a directive for that :

<tabs>
  <tab name="view">
    <pre>{{theText|formatInSomeWay}}</pre>
  </tab>
  <tab name="edit" focus="true">
    <input type="text" ng-model="theText" />
  </tab>
</tabs>

Well, know what ? <tabs> has its own scope, and broke your controller one ! So when you edit, angular will do something like this in js :

$scope.theText = element.val();

which will not traverse the prototype chain to try and set theText on parents.

EDIT : just to be clear, I'm only using "tabs" as an example. When I say "A lot of things introduce a new scope", I mean it : ng-include, ng-view, ng-switch, ng-controller (of course), etc.

So : this might not be needed as of right now, because you don't yet have child scopes in that view, but you don't know whether you're gonna add child templates or not, which might eventually modify theText themselves, causing the problem. To future proof your design, always follow the rule, and you'll have no surprise then ;).


Let's say you have scopes M, A, and B, where M is the parent of both A and B.

If one of (A,B) tries to write to M's scope, it will work only on non-primitive types. The reason for this is that non-primitive types are passed by reference.

Primitive types on the other hand, are not, hence attempting to write to theText on M's scope will create a new property of the same name on A or B's scope, respectively, instead of writing to M. If both A and B depend on this property, errors will happen, because neither one of them would be aware of what the other one is doing.