I had the exact same issue, where my numeric model was bound to both a type=number and a type=range.
IMHO, I don't think anything that looks like a number should be parsed as a number.
I do think that AngularJS should support a type=range as a numerical value, since that is what most users will use it for.
My workaround was to simply create a new directive, which requires the 'ng-model' directive, and adds a 'parser' to the NgModelController. This way there is no watching, and the model value never has an invalid value (i.e. a string instead of a number).
On Friday, July 20, 2012 1:17:47 PM UTC+3, Peter Bacon Darwin wrote:
Certainly works and seems like a good work around.
You could probably consider raising an issue on github for it, since a string that can be parsed to a float should probably be considered a number.
Thanks Peter! So is this a fair workaround (I've not used $watch before)?
On Friday, 20 July 2012 11:01:10 UTC+1, Peter Bacon Darwin wrote:
The other inputs are converting the model to a string, which is probably bombing out the validation on ngModel for the <input type="number"> element:
http://jsfiddle.net/TXazw/2/
With multiple inputs to the same model is it possible to get <input type="number" /> to play nice? It works as an input but updating it to a value set from another input always fails. Even if the source is also constrained as numeric (type="range" in chrome).
Hopefully this demonstrates my problem coherently:http://jsfiddle.net/TXazw/1/ Edit and input except the number and everything updates except the number input. Edit the number input and everything works fine.
I can't see anything in the
API reference, am I missing something?
Thanks
--
You received this message because you are subscribed to the Google Groups "AngularJS" group.