Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ng-money-mask

Package Overview
Dependencies
Maintainers
2
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ng-money-mask

Angular directive to mask inputs with currency values

  • 2.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created
Source

Angular Money Mask

An AngularJS (1.x) directive to mask inputs with currency values

** Para ler este documento em Português, clique aqui **

Usage

Download from npm or bower
$ npm install ng-money-mask --save

or

$ bower install ng-money-mask --save
Reference script file
<script src="rw-money-mask.min.js"></script>
Inject rw.moneymask module
const moneyMask = require('ng-money-mask');
...

angular.module('yourApp', ['rw.moneymask'])
Bind directive money-mask
<input type="text" name="price" ng-model="model.price" money-mask />

Obs: ngModel is required!

How it works

Model
  • Expects it to be a valid Javascript Number. e.g.: 100 ($ 100.00), 4.20 ($ 4.20), 4340.65 ($ 4,340.65)
  • It maintains the model value as a number. Only the input view gets formatted.
View
  • Displays formatted model value as the user types
  • It will allow only numbers to the input. Each time a number is put, the value updates.
  • Uses $filter('number'), which uses $locale.NUMBER_FORMATS configuration (separators, fraction size, etc) so it's i18n compatible.
Options

Use money-mask-append and money-mask-prepend to add some text to the formatted currency.

<input type="text" name="price" ng-model="model.price" money-mask money-mask-prepend="$" />

or

<input type="text" name="price" ng-model="model.price" money-mask money-mask-append="dollars" />

Development - Contribute!

  • Improvements are always welcome. Fork it and send a pull request!
  • English revisions to this document are more than welcome :)

Keywords

FAQs

Package last updated on 14 Nov 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc