salte-io / ng-currency Goto Github PK
View Code? Open in Web Editor NEWCurrency with AngularJS made easy!
License: MIT License
Currency with AngularJS made easy!
License: MIT License
I like to use ng-currency in a form. According to the $dirty states, I send the changed values to the backend on form submit. The form itself is set to $dirty, but the input itself, on which ng-currency is applied, is not set to $dirty... I quickly checked, if I can find the issue, but did not succeed. Can sombody check that? - Thanks in advance!
(I am using version: 0.8.6)
In version 0.8.9 and 0.8.8 when I place 22 in input and click outside, value disappears.
Code: <input required width="75" style="width: 75px" id="quantity" name="quantity" placeholder="quantity" ng-model="params.towar.qty" ng-pattern="CenaPattern" ng-currency currency-symbol=" " max="9999999999">
I tried with currency symbol {{' '}}
Everything works in 0.8.4 version.
Load 0.7.6 version... have a invalid bower.json .js path.
Could it be possible to add the github repository location in the package.json like;
"repository": {
"type": "git",
"url": "https://github.com/aguirrel/ng-currency.git"
},
Because its missing http://www.webjars.org will not repack the version from npmjs.com
Hello,
Please take a peek at this jsbin: http://jsbin.com/vaxupud/edit?html,js,output
Enter 5 in both fields and then press the Change min/max
button. Notice how the normal number field auto validates as being below the new min
value but the ngcurrency field does not. It seems that the validation for ngCurrency does not re-validate upon the min/max values changing.
Hi,
the version 0.9.5
has a change on focus function
if(isNaN(viewValue) || viewValue === '' || viewValue == null)
{
viewValue = '';
}
but, the folder dist hasn't changes this occured when i install the new version. maybe the relese has a problems.
in dist continue saied
viewValue = '0.00';
thanks for all ๐
Seems that something may have changed. Have started getting the following error, without any code changes:
Error: [$injector:modulerr] Failed to instantiate module ng-currency due to:
Error: [$injector:nomod] Module 'ng-currency' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.
Any thoughts? Potential upgrade in Angular?
we are using the cloudflare CDN.
Hello this is my first post to github. I found a bug. When i set ng-model to value in app controller and use ng-currency with currency symbol in input box, currency symbol initially is not set.
It works after clicking on input, so touch event is called.
I tried changing sequence in html input attribute, so ng-currency-symbol=" " went before ng-model.
I see the solution in my app by forcing click on input after page loads. Quite, it seems unellegant and doesn't solve problem for other users.
How can i repair this? I would like to have my first contribution to github by adding a patch to this code fixing this, but i don't know how to do this( forks, pull requests, commits). Is there any faq to this?
On your documentation you mention that for angular > 1.3.x we can use version 0.8.x.
I tried almost all the versions and all I am getting is:
bower ECONFLICT Unable to find suitable version for angular
Would you know anything on this issue ?
Any chance you could add the following:
I have two questions.
Is there any way to update on debounce, rather than blur?
I am trying to do something in an ng-repeat ("question in questions") and ng-currency is creating parsing issues. Is it possible to use ng-currency in this way? It is working fine without ng-currency, but I would love to use the currency formatting.
<input ng-currency type="text" class="form-control"
name="{{question.name}}" placeholder="{{question.placeholder}}"
ng-model-options="{ debounce: 200 }" ng-required="{{question.required}}"
min="{{question.min}}" max="{{question.max}}"
ng-model="model[question.name]">
And here is the copied and pasted error text:
Syntax Error: Token '{' invalid key at column 2 of the expression [{{question.min}}] starting at [{question.min}}].
If I remove the min field, then the parse issue shifts to the max or required fields, etc.
Thanks!
When I'm in input, I need delete format and when I get out show again, can you help me?
Hi, I need my max attribute to be set by the scope and it fails. Cf. plunker
Error: [$parse:syntax] Syntax Error: Token '{' invalid key at column 2 of the expression [{{max}}] starting at [{max}}]
cleaned
is set to null instead of the intended cleared
https://github.com/aguirrel/ng-currency/blob/master/src/ng-currency.js#L46
Hi i'm using ng-currency, and in my dev machine everything works fine, but when i upload my project to the server it shows me this error:
Error: [$compile:nonassign] http://errors.angularjs.org/1.3.20/$compile/nonassign?p0=undefined&p1=ngCurrency
i'm using the directive like this:
<input type="text" class="form-control" aria-label="Sale price of the property" ng-model="property.salePrice" id="salePrice" ng-currency />
and this is a caption of the error:
This only uses text input which makes it unintuitive on iOS and android
can you switch the currency symbol from left to right??
Why is the hard dependency on angular version 1.3.4?
Can it be used with e.g. 1.4.3 or are there known problems?
Does it support more than two decimal places?
The new "raw model on focus" feature from #48 gives some unfortunate drawbacks:
I suppose that the feature was intended to allow editing the amount without the currency symbols messing up the input: this would better be achieved by displaying formatted amount, just without currency or thousand markers:
$123.456,78 โ (currently) 123456.78 โ (i suggest) no change,
$123.456,70 โ (currently) 123456.7 โ (i suggest) 123456.70
$123.456,00 โ 123456 โ 123456.00
$0.00 โ Nan โ 0.00
This way, the user would always know what to expect from the input.
When you focus it pre-populates the input with 0.00
Looks like this was changed recently in #58 (line 170)
I've rolled back to v0.9.2 as this is undesirable behaviour and I can't imagine others would want this either as it creates a weird flow.
Hey, thanks for your module, it's cool.
Quick question, do you plan on adding an option to disable the currency symbol? I am using Bootstrap's input groups for showing the currency, so having it twice is kind of weird.
-edit-
As some suggestions, nice would be
-/edit-
Thanks for your response,
bcersows
It doesn't currently seem to support negative values either by entering -10 or (10). I'd like to use this for an invoice application I've been fiddling with and need to be able to apply credits and such represented by negative values.
Hi;
I want to use the input lie a content editable. If there would be a onBlur event callback, I could do this.
Thank you.
How can I set the number of decimal number after . ?
For example, I want $100.00 to be $100.
9999999999999999999 ng-model value round to 1000000000000000000
Loading up the Plunker (http://plnkr.co/edit/u9mJqDH8UpwxDnOv8gZL?p=preview), there is an error in the console right away:
TypeError: Cannot set property 'min' of undefined
And then on blur of the input, there is another error:
Uncaught TypeError: ngModel.$commitViewValue is not a function
When you blur/focus, the formatted value is incorrect
check out this plinker: http://plnkr.co/edit/FZW6dFyVKckO5QICN5XQ?p=preview
and try blurring.
what i can see is that the $$rawModelValue (in the focus event ) is not giving the correct value.
Hello,
I have an application which needs to work with different currencies at once (so this isn't something to solve with localization). These currencies are user-entered. I can't seem to find a way to use currency-symbol
to properly retrieve the correct symbol as well as support changes on the fly.
currency-symbol="{{getCurrency(myObject)}}"
works when the page is first loaded, but if getCurrency(myObject)
begins returning a different value, it is never evaluated again.
currency-symbol="{{getCurrency(myObject)}}"
causes the currency symbol to read "getCurrency(myObject)", instead of the more desirable return value.
The symbol does get updated when the contents of the input are rendered again. My guess is adding a watch on currency-symbol would probably solve it.
Hi. Currently using ng-currency on an input element like this:
<input id="input-paymentAmount" type="text" name="amount" ng-model="model.amount" ng-currency currency-symbol="$" required min="1.00" max="9999999.99"/>
If I enter a negative value (eg. -20), ng-invalid-min is set as expected while focussed but if I tab out of the field the validation is reverted back to ng-valid-min (which is incorrect).
Interestingly this only occurs for values <= -1 (in this instance). If i enter a value between -1 and 0 the validation works as expected. If I change the min value above to, say, 10 then the problem exists for values <= -10 but all values between -10 and 0 validate correctly.
Using ng-currency v0.8.6, angularjs v1.3.15
I would really appreciate it if you had a moment to investigate this.
Many thanks in advance
Here is the behaviour I see. On 0.8.5. I believe it is from something introduced in 0.8.3.
If a field has (say) a min and / or max range and you tab off it while it has an invalid value the field value is set to blank.
The reformatViewValue() function is run after a $commitViewValue and gets the $modelValue and runs the formatters over it and then sets the view value. I suspect $commitViewValue does not actually commit the value from the view to the model if there are validation failures. So, ngModel.$modelValue is actually undefined if the field view value fails validation .. meaning the formatters are executed on an undefined value, and that undefined value then becomes the new view value. Stuff goes blank then.
Perhaps consider using the $viewValue in reformatViewValue() rather than $modelValue?
is there any issue with it?
When in html input like this: <input type="text" width="55" style="width: 55px" id="CostAmount{{$index}}" name="CostAmount{{$index}}" placeholder="Price" ng-model="params.podtowar[$index].CostAmount" ng-pattern="PricePattern" ng-currency max="9999999999">
In Angular version 1.3.4 and ng-currency 0.8.9 i type negative number like -10 it formats to (10) which is fine, because so are defined negative prefixes and suffixes, but ng-model when i type negative number is undefined. I expect it to be -10.
There is any way for me to format while the user types instead of on blur?
The input value becomes zero after some blur event. Please see below:
http://g.recordit.co/1RzA19bbkn.gif
Code is:
<input type="text" ng-currency fraction="2" currency-symbol='man.' ng-model="testModel">
I tested in plunker but it works there. What can be the reason?
It would be great if repo comes with a package.json
and module be compatible with Browserify
, even better if you could publish a version of module to npm
as well.
Hello,
I'm using your directive which workes fine, but I'm facing an issue adding an other one with isolated scope to my element. Could you try some changes with a new scope instead of isolated one?
...
require: 'ngModel',
scope: true,
link: function (scope, element, attrs, ngModel) {
scope.min=attrs.min;
scope.max=attrs.max;
scope.currencySymbol=attrs.currencySymbol;
scope.displayZeroes=attrs.displayZeroes;
scope.ngRequired=attrs.ngRequired;
scope.fraction = attrs.fraction;
...
Regards,
My model keeps value in cents but I want the users to edit the value in dollars. I created a simple directive that transforms the value to cents and back. Unfortunately the onblur event in your directive assumes that it's the only one on this element and it formats the view value using only the currency formatter. It should transform the modelValue using all $formatters instead.
Look at this demo: http://jsfiddle.net/9kkd9631/ and see what happens when you trigger the blur event on the first input.
Currently, if the locale setting is to use decimal comma, then typing "0.50" in the input transforms it into "50,00", and that's quite bad.
I patched it locally so that the decimalRex and clearRex would use a separator regex, and pass the default of '[.,]' โ it works beautifully for my needs, but I'm not sure if that's i18n enough.
If a maxlength attribute is specified for an input and on focus the input length reaches the maxlength value, on blur the addition of commas or decimal zeros may push the input length over the specified maxlength at which point the variable bound by ng-model defaults to undefined.
First, let me thank you for this creating this useful module! I found a (minor, yet for my application severe) bug though:
I noticed that the model value is incorrectly rounded to the initial fraction instead of the current fraction.
I created a Plunker to illustrate the bug
As you can see in the plunker, the "fraction" attribute of the input is bound to $scope.fraction. The decimal places are correctly displayed after $scope.fraction is changed to 5, but if you enter a value in the input field, eg. 0.0001, the value is rounded (actually floored) to 2 decimal places, the initial value of the fraction attribute. So the $scope.testVariable is now still 0 if I enter any value smaller than 0.01, even though the input field displays 5 decimal places.
When having ng-model connected to input with ng-currency directive in version 0.8.9 and Angular 1.3.4.
When I type number in input and then remove it ( by hitting backspace ) ng-model associated has NaN value. Is it expected behaviour?
Hello,
great directive. It always removes values if I have type="number". I want to have number type so on the smart phones shows only numeric keyboard. Is it possible to fix this?
Thank you!
Regards,
Simon
Hello @aguirrel
Very nice directive :)
I am missing the "currencyRedraw" $broadcast listener, as mentioned in the documentation.
It isn't in the directive and it's an important feature, to be able to update input fields when changing locale dynamically.
I have added it my self, but I think it would be nice for others if it was included.
element.on('focus',function(){
ngModel.$setViewValue(ngModel.$$rawModelValue || '');
ngModel.$render();
});
it is not an issue just want to add this feature, when focus on the input rest to raw model value so that easy to modify the value.
When entering a number with 20 or 21 digits the value displayed in the input field is $NaN.00 (see image). This doesn't seem to happen for values as large as 999999999999999999999 (21 "9's").
<div class="col-lg-2">
<input type="text" id="estCost" class="form-control"
data-ng-currency data-currency-symbol="$"
placeholder="Estimated Cost" data-ng-model="ctrl.request.estCost"/>
</div>
If the initial value of the input field is null there will be an error on focus saying
Uncaught TypeError: Cannot read property 'toFixed' of null
could you add a null check on focus on the viewValue?
Hi, this is a great lib for my app. But is there a way to remove the currency symbol?
I'm using the new debouncing features of ng-model-options. I noticed that with ng-currency and debouncing that the value in the form field isn't matching the value on the scope.
Here's an example that should reproduce the issue.
An ngCurrency text input whose model is undefined is considered to be invalid if it has the following attributes set:
max="[anything]"
ng-required="true"
If the model value is null
or empty string, everything works. It only breaks if the model value is undefined
. If the required
attribute is used instead of ng-required
everything works.
Here is a plunker that shows the problem.
http://plnkr.co/edit/n4lFQQTOMwzolYI7SANS?p=preview
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.