Skip to content

Angular filter that takes a currency string or number and converts it to longhand text.

Notifications You must be signed in to change notification settings

fugitivelabs/angular-num2txt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AngularJS number to text filter

This is a simple filter that takes a number or currency string from input or $scope and converts it to longhand text.

For example:

  • 3425 becomes Three Thousand Four Hundred Twenty-Five
  • $422.73 becomes Four Hundred Twenty-Two and 73/100

Dependencies

Install

  1. Copy or download the angular-num2txt.min.js file to your project.
  2. Reference the file in your html
  3. Include the module in angular (i.e. in app.js) - angular-num2txt

Documentation

Reference angular-num2text in your HTML after angular and before your project app.

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.js"></script>
<script type="text/javascript" src="angular-num2txt.min.js"></script>
<script type="text/javascript" src="app.js"></script>

Include the module in your angular.

angular.module('myApp', [  
  "angular-num2txt"
])
.controller('HomeCtrl', ['$scope', function($scope) {
  console.log('HomeCtrl loaded...');
  $scope.number = 33449.67;
  $scope.currency = "$467.43";
}]);

Add the num2txt filter to whatever number or currency string you'd like to display as longhand.

<div ng-controller="HomeCtrl">
  <input type="number" ng-model="number">
  <p> {{ number | num2txt }} </p>

  <input type="text" ng-model="currency">
  <p> {{ currency | num2txt }} </p>
</div>

About

Angular filter that takes a currency string or number and converts it to longhand text.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published