angularjs-filters

A library of common AngularJS filters.

Homepage

Module License: MIT

Added by: Sam Deering

GitHub

Repository

sumitchawla/angularjs-filters

Stats

Stars: 18

Watchers: 18

Forks: 3

Module Description

Build Status Dependency Status devDependency Status

angularjs-filters

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).

Installation

bower install angularjs-filters

String Filters

Filter Usage Result
string.format 'Hello {0}. What are you been doing this {1}?' | string.format : 'Sam' : 'evening' Hello Sam. What are you been doing this evening?
string.html2string 'Hello <br/>. How are you?' | string.html2string Hello . How are you?
string.shorten 'A long story cut into short' | string.shorten : 12 A long story...
string.replace
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
string.camelcase 'A long story cut into short' | string.camelcase A Long Story Cut Into Short
string.lowercase 'Convert to LOWERCASE' | string.lowercase convert to lowercase
string.uppercase 'uppercase all' | string.uppercase UPPERCASE ALL
string.trim, string.trimstart, string.trimend
String Trim Functions
' Hello Mr. ' | string.trim Hello Mr.

Array Filters

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

Math Filters

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

Boolean Filters

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

Debug Filters

Filter Usage Result
debug.print
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.

Contributions

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

Module stats last updated: 2017-05-12 16:00:05

Disclaimer: Some data on this page may have been gathered from the authors GitHub respository. If you see any mistakes or outdated information please let us know. Thanks!