Open yerdn opened 8 years ago
Thank you for your contribution! At weekend I will review it. But at first glance It looks ok.
Hello,
I have added few more fixes: Keeping cursor on current position on invalid input. Preventing multiple entry of the prepend and append symbols in empty input.
Regards, Andrey
Hey It need a little more time to approve it, because tests are failing. Im checking if there is a bug or if I should change tests.
@yerdn can you explain how it should work. Maybe write here in comment how directive with this argument should look like. I ask because it isn't working for me:
I created directive :
<input type="text" ng-trim=false ng-model="someModel" awnum num-int=4 num-fract=4 num-fixed=true >
And when I type for example "1" I expect model equal 1.0000
I think I can't work because in version 2.0.0 model is always number. And number 1.0000
will be converted automatically to 1
.
If I type "1.12345" then I expect model to be equal "1.1234". And this works but it works because of num-fract=4
Maybe you can add working example (examples/index.html
) or write test for it (test/directiveSpec.js) ?
Hi Krzysztof,
numFixed parameter should work the same way as numFixed option for filter. From your documentation "If true then there is fixed number of fraction digets - (useful when fraction part is 00 and we need to show this zeros e.g. 12,00 )". It should be the same behaviour, so it is a combiation of num-fract and num-fixed I suppose.
But both of them has different output. Filter output is string and directive output is javascript number. Therefore in my opinion directive even if works with numFixed in output will change to number ( for example "1.00" will change to "1"). But I can be wrong, does it works for you? If yes please write working example code.
Added numFixed parameter to options (same as for filter). Fixed bug with prepend and append symbols doubling on invalid input. Don't default model to zero on invalid input so user can unset values. Adding fractions part on blur event if numFixed="true".