Created
May 13, 2015 10:47
-
-
Save chrishutchinson/67f8dbb84854dee7219d to your computer and use it in GitHub Desktop.
AngularJS (ES6) filter wrapper for NumberStrings (https://www.npmjs.com/package/numberstrings)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
// Import class | |
import NumberStrings from 'path/to/numberstrings.filter'; | |
angular.module('appName', []) | |
.filter('NumberStrings', () => new NumberStrings()) // Add filter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
// Require module | |
var NumberStringsModule = require('numberstrings'); | |
// Setup NumberStrings class | |
class NumberStrings { | |
constructor () { | |
// Load module | |
var ns = new NumberStringsModule(); | |
return function(input) { | |
// Replace commas in input | |
input = parseInt(input.replace(/\,/g,''), 10); | |
// Return formatted number | |
return ns.format(input); | |
} | |
} | |
} | |
// Export class | |
export default NumberStrings; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment