fiestah / angular-money-directive Goto Github PK
View Code? Open in Web Editor NEWAngularJS directive to validate monetary inputs
AngularJS directive to validate monetary inputs
I understand in the README it says not to use type=number for the input, but why is this?
When using different number formats (i.e. currency symbol) defined by angular locale the directive needs to reflect that visually and also allow those characters to be entered in the money field. Currently the directive is en-US and $ only (or other locales that overlap).
Is there a way to allow any and all negative numbers? I could set min="-9999999"
but I'd rather be able to not set a minimum at all...
Hi and thank you.
Can you please update the code to the design of Angular 1.3.x?
Use $validators
for validation for instance.
Thank you.
Enter some number which will is invalid. For example when min="2"
, max="10"
:
123
Press any invalid char, a letter for example l
. The field gets cleared.
I would expect the invalid value 123
will not change.
Enter some number which will be rounded:
12.3456
Press tab
or click outside to leave the field. The value will be rounded:
12.35
Focus on the field and press any invalid char, a letter for example l
. The previous, not rounded value is shown:
12.3456
.
I would expect the value 12.35
will not change.
Can you append how to use your directive in one example ?
<input type="money" ng-model="price" />
with this previous declaration :
var MainApp = angular.module('MainApp', ['fiestah.money']);
Best regards,
Stephane
[ x ] prevents alphanumeric characters
[ x ] prevents negatives when min=>1
[ ] autoformats string to ##.## onBlur
I am probably missing something obvious, but maybe this is a 'doc bug'.
Anything I can check before reading the code?
Thank you for your solution!
There is very big issue I think. If I put your directive to my input, angular form become dirty from the start.
Are you plan to fix this in nearest time, because I want to use your directive in my project?
Thank you.
Do you have plans to add it to bower ? The name angular-money-directive
is free there.
If the model is updated in the background (i.e. not by typing in the input field) to be zero (0), the input field then displays a blank string, instead of a properly formatted numeric number 0 (when 0 is supposed to be a valid value). If I type in a zero (0), then the input field displays the correctly formatted string.
Hi and thank you.
I have a situation where I need to dynamically set min
, max
and precision
, but right now the directive preserves the initial values it finds.
Thank you.
If precision is not set explicitly I always get NaN because of the round function
when i enter number above thousand (100000.00) it is not adding the comma (,) to separate the numbers. i would like to have 100,000.00 rather than 100000.00
Hello.
It would be great if the repo contained also minified version + source map.
Thank you.
Directive does not seem to work with 1.3.7, but does work with 1.2.25
I have this:
<input type='text' precision='2' max='99999999999.99' min='0.01' ng-model='salary' />
The value in the model is 0.01. It is being displayed as 0 until you visit the field and tab out. This is due to ngModelCtrl.$render() not being called in the precision observe callback,
Hi I am using your directive and i love it.
Is there any way to make it work with input type="number"?
It is particularly for mobile so that when the input field is in focus, it brings up the number key pad rather than text keyboard.
Hi,
The demo looks great, however the directive does not work and I have 0 errors. If I type any number, the input field stays blank and if i type 0 it actually populates it. Typing 0 doesn't actually update it on the model or scope however typing anything else returns NaN. Im on angular 1.2.*(latest)
Any ideas?
Cheers
改进:将三个return null; 改为 return ;
Directive definitions do not follow the minification guildelines:
.directive('money', function($parse) { ... })
Should be
.directive('money', ['$parse', function($parse) { ... }])
Can you please fix?
The directive's module can no longer be loaded after code is minified. I did not see an $inject array with string parameters for your injection.
See here: https://docs.angularjs.org/tutorial/step_05#a-note-on-minification
working on it.
Hi,
I'm able enter + sign within the text box, How can i avoid this ?
Example : +444.22
First i will enter a number like 444.22 and then i can add + symbol at the beginning of the text box.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.