node package manager
Love JavaScript? Your insights can make it even better. Take the 2017 JavaScript Ecosystem Survey »


Build Status Dependency Status devDependency Status


A library of common AngularJS filters. Each filter is individually tested for various inputs. The module can be used by using the filter.js in your browser includes, or by using npm module ( with browserify).


bower install angularjs-filters

String Filters

Filter Usage Result
format 'Hello {0}. What are you been doing this {1}?' | string.format : 'Sam' : 'evening' Hello Sam. What are you been doing this evening?
html2string 'Hello <br/>. How are you?' | string.html2string Hello . How are you?
shorten 'A long story cut into short' | string.shorten : 12 A long story...
String Replace. Pattern can be a string or regex
'Hello Mr How are you doing' | string.replace : 'Mr': 'Sir'
"hello help"| string.replace:"he[a-z]{2}":"Yell"
Hello Sir How are you doing
Yello Yell
camelcase 'A long story cut into short' | string.camelcase A Long Story Cut Into Short
lowercase 'Convert to LOWERCASE' | string.lowercase convert to lowercase
uppercase 'uppercase all' | string.uppercase UPPERCASE ALL
trim, trimstart, trimend
String Trim Functions
' Hello Mr. ' | string.trim Hello Mr.

Array Filters

Filter Usage Result
join ['Hello','Mr.','How','Are','You?'] | array.join : '-' Hello-Mr.-How-Are-You?
reverse ng-repeat='["Banana", "Orange", "Apple", "Mango"] | array.reverse' "Mango","Apple","Orange", "Banana"

Math Filters

Filter Usage Result
max [8, 1, 2, 3, 7] | math.max 8
min [8, 1, 2, 3, 7] | math.min 1

Boolean Filters

Filter Usage Result
Converts boolean value to Yes/No
A == B | binary.YesNo Yes/No?

Debug Filters

Filter Usage Result
Debug prints the bound value
'MyValue' | debug.print MyValue

Unit Testing

Each of the filter is covered by Unit Test extensively. If you find any input unhandelled, please let me know. Run the unit tests using following commands:

npm run karma 
npm run karma2


Please feel free to add your contributions to set of filters.