Capitalization of First Letter in Angular with a Custom Filter (And JavaScript generally too).

Capitalization of First Letter in Angular with a Custom Filter (And JavaScript generally too).
Capitalization of First Letter in Angular with a Custom Filter (And JavaScript generally too).

Capital not Capitol.

Angular has some great built in filters, but one case that comes up the Angular doesn’t handle automatically capitalizing the first letter in a string. (Skip to the bottom to get the code snippet if you don’t care about my babbling)

For capitalizing the first letter, but leaving the rest of the string the same, we’ll use the substring, toLowerCase and toUpperCase methods.

I’m assuming you have a module set up, I’m using the app convention.

The regular JavaScript for capitalizing goes like this: Continue reading “Capitalization of First Letter in Angular with a Custom Filter (And JavaScript generally too).”