How to autocapitalize the first character in an in

2019-01-05 10:04发布

How to autocapitalize the first character in an input field inside an AngularJS form element?

I saw the jQuery solution already, but believe this has to be done differently in AngularJS by using a directive.

14条回答
我想做一个坏孩纸
2楼-- · 2019-01-05 10:38

You can use the provided uppercase filter.

http://docs.angularjs.org/api/ng.filter:uppercase

查看更多
手持菜刀,她持情操
3楼-- · 2019-01-05 10:39

Use the CSS :first-letter pseudo class.

You need to put everything lowercase and after apply the uppercase only to the first letter

p{
    text-transform: lowercase;
}
p:first-letter{
    text-transform: uppercase;
}

Here's an example: http://jsfiddle.net/AlexCode/xu24h/

查看更多
登录 后发表回答