Skip to content

Instantly share code, notes, and snippets.

@builtbylane
Created October 30, 2013 18:43
Show Gist options
  • Star 24 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save builtbylane/7237798 to your computer and use it in GitHub Desktop.
Save builtbylane/7237798 to your computer and use it in GitHub Desktop.
AngularJS – filter: removes white space from text. useful for html values that cannot have spaces
/**
* Description:
* removes white space from text. useful for html values that cannot have spaces
* Usage:
* {{some_text | nospace}}
*/
app.filter('nospace', function () {
return function (value) {
return (!value) ? '' : value.replace(/ /g, '');
};
});
@SujathaMaddala
Copy link

SujathaMaddala commented Jan 19, 2017

var app=angular.module("myModule", [])
.controller("myController",function($scope)
{$scope.transformString=function (input){
if(!input){
return input;}
var output="";
for(var i = 0; i < input.length;i++)
{
if(i>=0 && input[i]==input[i].toUpperCase())
{
output = output + " ";
}
output = output + input[i];
} $scope.output=output;
}});
this is the JS code for removing spaces in another text box

Your String Result

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment