0

I set the input value Array property sum and it shows value in input but when submitting form does not get Quantity property in Order object. If I change the value then I get Quantity property value. How can I get model value from ng-value?

<input ng-model="Order.Quantity" ng-value="subOrderList.sum('Quantity')" type="number">
user752
  • 68
  • 7
Mohammad Ali Rony
  • 4,695
  • 3
  • 19
  • 33

1 Answers1

0

To answer your question, "ng-value does not update Ng-model", it is by design. As mentioned in comments, ng-value and ng-model are not intended to by used in this way.

It isn't entirely clear what you are trying to achieve here, so here's a couple potential solutions:

If you are just looking to display a value then you don't need to use an input at all. Both of these will behave the same and update when needed:

<span>{{subOrderList.sum('Quantity')}}</span>

<span ng-bind="subOrderList.sum('Quantity')"></span>

If you actually need this value to be updated by user input then the HTML would look like this:

<input ng-model="Order.Quantity" type="number">

And then you will need to manually update that value in a controller or service when needed:

Order.Quantity = subOrderList.sum('Quantity');

From your comments it almost seems like you need an input that also changes dynamically and sporadically, but without a data example or more code I can't really see how that would work.

user752
  • 68
  • 7