Expand Minimize

Always have . in ngModel

Always have . in ngModel

CheckId NG1011002
TypeName AlwaysHaveDotInNgModel
Severity CriticalWarning
Type Template

AngularJS uses prototypical inheritance to expose properties from parent scope to child scopes. For primitives, the connection to the parent exists until the value is changed in one of the child scopes. At that moment, the child scope gets its own property that hides the parent property with the same name. From now on, the updated value from the parent won't be propagated to child scopes. If you use an object instead of a primitive, the link to the original value is maintained, even if you set the value in a child scope.


Good practice

<input type="text" ng-model="obj.name">


Bad practice
<input type="text" ng-model="name">

Disclaimer: The views and opinions expressed in this documentation and in SPCAF do not necessarily reflect the opinions and recommendations of Microsoft or any member of Microsoft. SPCAF and RENCORE are registered trademarks of Rencore. All other trademarks, service marks, collective marks, copyrights, registered names, and marks used or cited by this documentation are the property of their respective owners.