GithubHelp home page GithubHelp logo

ng-currency's People

Contributors

aguirrel avatar cecilia-sanare avatar ctesene avatar davestaab avatar dependabot-preview[bot] avatar dependabot[bot] avatar greenkeeper[bot] avatar gsandoval avatar jaxbot avatar luftywiranda13 avatar mgoku avatar ognus avatar oriolcp avatar rikukissa avatar robsecord avatar rothlis avatar semantic-release-bot avatar vjanssens avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

ng-currency's Issues

used in a form, $dirty is not set on the input

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)

Input value disappear on blur

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.

Dist not actualized

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 ๐Ÿ‘

Unable to instantiate ng-currency

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.

ng-model initially set and currency-symbol attribute - initially currency symbol doesn't refresh to valid.

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?

Bower install fails

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 ?

Feature suggestions

Any chance you could add the following:

  1. Decimal places always have trailing 0 in the model value. I.e. $1.50 = 1.50, not 1.5.
  2. Option to set the model value in cents. I.e. $1.50 = 150

Does not work with dynamic fields

I have two questions.

  1. Is there any way to update on debounce, rather than blur?

  2. 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!

Error if max is a scope value.

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}}]

rawModelValue formatting

The new "raw model on focus" feature from #48 gives some unfortunate drawbacks:

  1. having actual "0.00" (as a specific 0.00, not null, not Nan, not undefined) amount, the amount completely disappears as not entered at all on re-focusing;
  2. it's not exactly "raw" value: if i've entered "0.40", I'd probably expect to see "0.40". Instead the leading zeroes are stripped, and I have to visually confirm if what I'm editing is what I actually intended to.

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.

On focus pre-populating with 0.00

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.

Disabling showing currency symbol

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

  • parameter to not show any currency symbol at all (no-currency-symbol)
  • parameter to hide currency symbol when clicking into the input field (hide-currency-symbol)

-/edit-

Thanks for your response,
bcersows

Negative values

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.

Possiblity to add onBlur event?

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.

Allow dynamic currency-symbol

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.

min value validation ignored on blur for negative numbers

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

Field value empties when invalid

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?

When having negative numbers, value of ng-model is undefined.

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.

Add Support of commonjs (Browserify)

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.

Avoid using isolated scope

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,

ng-currency doesn't play well with other directives when loosing focus

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.

Both dot and comma separators probably should be treated as decimal separators

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.

Input Exceeds Max Length on Blur Resulting In Undefined ngModel

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.

Model value is incorrectly floored when fraction is changed dynamically

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.

Setting default value after emptying input box

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?

Not working with type="number"

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

currencyRedraw

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.

reset to $$rawModelValue when input on focus

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.

"Not A Number" Displayed for values of 20 or 21 digits (within some range)

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>

With 888888888888888888888 (21 8s):
image

With 999999999999999999999 (21 9s):
image

Error if viewValue is null

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?

Issues with ng-model-options

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.