format-as-currency-code
Angular directive to format an input as a currency code as the user types. Like autoNumeric for Angular.
Installation
Install via bower or NPM:
- Bower:
bower install --save format-as-currency-code
- NPM:
npm install --save format-as-currency-code
Usage
<div ng-controller="myController">
<input
format-as-currency-code
currency-code="CLP"
ng-model="value"
type="text"
>
</div>
<script src="bower_components/angular/angular.js"></script>
<script src="bower_components/format-as-currency/format-as-currency-code.min.js"></script>
<script>
angular
.module('myModule', [
'bcherny/formatAsCurrencyCode'
])
.controller('myController', function ($scope) {
$scope.value = '' // currency input value
})
</script>
With a custom curency formatter
<input
format-as-currency
currency-code="COP"
currency-filter="'myFilter'"
ng-model="value"
type="text"
>
<script>
angular
...
.filter('myFilter', function () {
return function (value) {
return '¥' + value
}
})
</script>
With a module loader
Browserify
var formatAsCurrencyCode = require('format-as-currency-code')
angular.module('myModule', [formatAsCurrencyCodeCode])
Rollup
import * as formatAsCurrencyCodeCode from 'format-as-currency-code'
angular.module('myModule', [formatAsCurrencyCodeCode])
Webpack
var formatAsCurrencyCode = require('format-as-currency-code/src/format-as-currency-code')
angular.module('myModule', [formatAsCurrencyCodeCode])
Running the tests
npm test
Contributing
Contributions are welcome! Please be sure to:
- File an issue for the problem that your PR addresses
- Test your fix thoroughly
- Follow the existing code style
- Add unit tests to cover your feature, or to prevent future regressions