Search code examples
angularjsangular-ngmodelng-bind

Issue displaying value in number field AngularJS


I am trying to bind a value which of type string when it comes from the controller in a numeric input field like the following:

<input type="number" ng-model="detail.Value">

Since the detail.Value is of type string, I value is not getting displayed (I guess).

I can not change the Value property's type to int.

What can I do in the view to display the value in the number box?


Solution

  • Wrap it with parseFloat:

     detail.Value = parseFloat(detail.Value);
    

    Demo Fiddle