Skip to content

Instantly share code, notes, and snippets.

@paulakreuger
Last active October 18, 2023 19:34
Show Gist options
  • Save paulakreuger/b2af1958f3d67f46447e to your computer and use it in GitHub Desktop.
Save paulakreuger/b2af1958f3d67f46447e to your computer and use it in GitHub Desktop.
Capitalize First Letter Filter - AngularJS
app.filter('capitalize', function() {
return function(input, scope) {
if (input!=null)
input = input.toLowerCase();
return input.substring(0,1).toUpperCase()+input.substring(1);
}
});
@simonewebdesign
Copy link

Can you explain me how it works?

The idea is to convert the string to lower case, then let CSS capitalize each first letter. It can be necessary if you need to prevent the edge cases mentioned by @martininf.

@HarshJains
Copy link

HarshJains commented Jul 26, 2020 via email

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