Capitalize first letter of a string using Angular or typescript
This question already has an answer here:
function titleCaseWord(word: string) {
if (!word) return word;
return word[0].toUpperCase() + word.substr(1).toLowerCase();
}
You can also use in template TitleCasePipe
Some component template:
{{value |titlecase}}
var str = 'santosh';
str = str ? str.charAt(0).toUpperCase() + str.substr(1).toLowerCase() : '';
let str:string = 'hello';
str = str[0].toUpperCase() + str.slice(1);
链接地址: http://www.djcxy.com/p/17872.html
上一篇: 首字母大写Jquery