Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Some inputs inside ng-switch don't update the model when changed #1139

racheldale opened this Issue · 3 comments

4 participants


Inputs that point to fields directly on the scope (e.g. data-ng-model="fieldName") don't update when inside of an ng-switch case. This works fine for fields that are inside an object (e.g. data-ng-model="item.fieldName").

Here is an example:


@racheldale This works as intended. The ng-switch directive creates a new scope and the input binds to the fieldName in this new scope, instead of the parent one. Scopes prototypically inherit from each other, AngularJS just behavior is consistent with behavior of regular JavaScript objects. More info here:


Yes you are right. ng-switch creates a new scope and so ng-model is writing to an inner scope value and the outer scope value does not get updated. As you say, use objects to refer to the field.


Here is the modified working fiddle for the pragmatic people out there:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.