npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

angular-currency

v1.0.7

Published

An angular directive that utilizes autoNumeric to format an input field as currency as a user types

Downloads

835

Readme

Angular Currency Directive

Current Version

v1.0.6

Description

This is an angular 1.x directive that utilizes AutoNumeric to format an input field as currency as a user types.

Example

Plunker

Usage

  • 'bower install angular-currency'
  • Include autoNumeric.js which should be located at `bower_omponents/autoNumeric/autoNumeric.js'
  • Include 'angular-currency' provided by this component into your app
  • Add bckrueger.angular-currency as a module dependency to your app

HTML

<input type="text" ng-model="currency" angular-currency="options" variable-options="true" />

Directive Attributes

angular-currency: The options to be passed into AutoNumeric

variable-options: If you will be using dynamic options this needs to be set to true, otherwise the directive will not watch for options updates and update AutoNumeric

Options

Angular Currency allows for all options supported by AutoNumeric.

"aSep": controls the thousand separator character

  • aSep: ',' comma (default)
  • aSep: ''' apostrophe (note: the apostrophe is escaped)
  • aSep: '.' period
  • aSep: ' ' space
  • aSep: '' none

"dGroup": controls the digital grouping and the placement of the thousand separator

  • dGroup: '3' produces 333,333,333 (default)
  • dGroup: '2' produces 22,22,22,333 (India's Lakhs format on values below 1 billion)
  • dGroup: '4' produces 4,4444,4444 used in some Asian country's

"aDec": controls the decimal character

  • aDec: '.' period (default)
  • aDec: ',' comma

"altDec": this was developed to accommodate for different keyboard layouts. altDec allows you to declare an alternative key to enter the decimal separator assigned in aDec

  • altDec: null (default)

"aSign": displays the desired currency symbol (examples: € or EUR). Note: other symbols can be used, such as %, °C, °F, km/h & MPH the possibilities are endless

  • aSign: '' none (default)
    • example - aSign: 'U$D'

"pSign": controls the placement of the currency symbol (prefix or suffix)

  • pSign: 'p' prefix to the left (default)
  • pSign: 's' suffix to the right

"vMin": controls the minimum value allowed

  • vMin: '-9999999999999.99' (default)
    • example - vMin: '0.00'

"vMax": controls the maximum value allowed

  • vMax: '9999999999999.99' (default)

Note - setting the vMin and vMax to both positive or negative with situations that limits the users ability to enter the proper values

"mDec": overrides the decimal places that that are set via the vMin/vMax values

  • mDec: null (default method)
    • example - mDec: '4'

"mRound": sets the rounding method used (10 different available)

  • mRound: 'S' Round-Half-Up Symmetric (default)
  • mRound: 'A' Round-Half-Up Asymmetric
  • mRound: 's' Round-Half-Down Symmetric (lower case s)
  • mRound: 'a' Round-Half-Down Asymmetric (lower case a)
  • mRound: 'B' Round-Half-Even "Bankers Rounding"
  • mRound: 'U' Round Up "Round-Away-From-Zero"
  • mRound: 'D' Round Down "Round-Toward-Zero" - same as truncate
  • mRound: 'C' Round to Ceiling "Toward Positive Infinity"
  • mRound: 'F' Round to Floor "Toward Negative Infinity"
  • mRound: 'CHF' Rounding for Swiss currency "to the nearest .00 or .05"

"aPad": controls padding of the decimal places

  • aPad: true always pads the decimal with zeros (default)
  • aPad: false no padding

"nBracket": controls if negative values are display with brackets when the input does not have focus

  • nBracket: null no brackets use for negative values (default)
  • nBracket: '(,)'
  • nBracket: '[,]'
  • nBracket: '{,}'
  • nBracket: '<,>'

"wEmpty": controls input display behavior

  • wEmpty: 'empty' allows input to be empty (default)
  • wEmpty: 'zero' input field will have at least a zero value
  • wEmpty: 'sign' the currency symbol is always present### Methods that are supported:

"lZero": controls leading zeros behavior

  • lZero: 'allow' allows leading zero to be entered. They are removed on focusout event (default)
  • lZero: 'deny' leading zeros not allowed.
  • lZero: 'keep' leading zeros allowed and will be retained on the focusout event

"aForm": controls if default values are formatted on page ready (load)

  • aForm: true default values are formatted on page ready (default)
  • aForm: false default values are NOT formatted on page ready

"anDefault": helper option for ASP.NET post-back

  • should be the value of the un-formatted default value
  • this can be set as an option or HTML5 data
  • examples:
  • no default value='' {anDefault: ''}
  • value=1234.56 {anDefault: '1234.56'}

Additional Info

Unit Tests

Unit tests are done with Karma using Mocha and Chai

Code Quality

Code quality is ensured using JSHint