Skip to content Skip to sidebar Skip to footer

Ng-model In Numeric Input Does Not Affect Scope

ng-model does not affect the scope and I can't understand why. Here is most of my HTML:

Solution 1:

Updated answer:

Following up on Sunil D and Dayan Moreno's comments to the question, throwing the primitive value inside an object is the best approach, and avoids having to use $parent in your code:

ng-model='object.amount'

As long as object doesn't exist in the child scope, it will refer to the object variable found in the parent scope and set the amount value appropriately.

Original answer:

Having not used ion yet, I would assume that either ionView or ionContent is a directive which creates its own scope.

You're setting the value property of a child scope, then trying to access the value property of the parent scope. Accessing the parent scope's amount value might solve the issue for you:

ng-model='$parent.amount'

Post a Comment for "Ng-model In Numeric Input Does Not Affect Scope"