When using ng-model for input, I want to maintain the original value if an invalid number is entered. How can I accomplish this? For reference, visit the Plunker at: http://plnkr.co/edit/wX7n0jBn1Ek1py4DJHqT?p=preview
The input box utilizes ng-model for binding the value and is defined with a type of number.
<input type="number" name="input" ng-model="example.value" min="0" max="99" required>
Currently, when changing the input, the ng-model also changes simultaneously. Is it possible to delay this change until a valid number is entered? Can ng-change be used for this purpose, or does the ng-model update immediately upon input change, making it difficult for ng-change to retain the original value?
Let's consider an example for clarification:
If the current ng-model value is 10, and I input 50, it will update to 50. Subsequently inputting 5000 will change the value to 5000.
Conversely, if the current value is 10 and I input 'aaa', it should revert back to 10.
Specifically, how can I create a copy of the ng-model to restore the original value when using onchange in the input box?