Skip to content

Instantly share code, notes, and snippets.

@gerisztein
Last active August 29, 2015 14:06
Show Gist options
  • Save gerisztein/70973235c819b232bf86 to your computer and use it in GitHub Desktop.
Save gerisztein/70973235c819b232bf86 to your computer and use it in GitHub Desktop.
White Space Replace Angular Filter
/*
* Angular Filter to Remove White Spaces in Expression
*
* usage: {{ text | whitespace:'str' }}
* the argument is optional, the default value is null.
* white spaces will be replaced by 'str'.
*
*/
app.filter('whitespace', function () {
return function (val, rep){
rep = rep || '';
return (!val ? '' : val.replace(/ /g, rep);
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment