New to Angular, and have this simple issue cannot get resolved: I have this html
<input type="number" max="20" step="0.1" name="est_mpg" id="est_mpg" data-ng-model="est.mpg" class="form-control" value="5.00" />
I cannot get default value to show up, what happens it flashes and than disappears, so the box is empty, and i can tick up/down from default min value. It worked fine until I turned the input to type="number" from text.
The default stepping value for number inputs is 1 , allowing only integers to be entered—unless the stepping base is not an integer.
The <input type="number"> defines a field for entering a number. Use the following attributes to specify restrictions: max - specifies the maximum value allowed. min - specifies the minimum value allowed.
The angular. isNumber() function in AngularJS is used to determine the parameter inside isNumber function is a number or not. It returns true if the reference is a number otherwise returns false.
Use GruffBunny' solution or as an alternative use ng-init
instead of value
:
ng-init="est.mpg=5.00"
Fiddle: http://jsfiddle.net/aY8rE/
Default the value of est.mpg to 5.00 in the controller and remove the value attribute.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With