If Angular's ng-model seems disconnected ...

2015-07-01 | #angular, #solution, #webdev

Say you defined a simple ng-model-binding on a text input and now you're wondering, why the hell the value does not update in the controller. This is the result of some weird js-prototyping fuckup if you are connecting directly to a scope-value.

To circumvent this you'll have to wrap every value being manipulated by ng-model in an object. So instead of

<input type="text" ng-model="name"/>

you would have to do something like

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

As a rule of thumb: if you're using ng-model, there's gotta be a dot in it.