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.
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.
To fix the cursor problem (from where Mark Rajcok's solution), you can store element[0].selectionStart at the beginning of your method, and then ensure to reset element[0].selectionStart and element[0].selectionEnd to the stored value before the return. This should capture your selection range in angular
The problem with css-ony answers is that the angular model is not updated with the view. This is because css only applies styling after rendering.
The following directive updates the model AND remembers the cursors location
I would prefer a filter and directive. This should work with cursor movement:
Here is a fiddle
Yes, you need to define a directive and define your own parser function:
HTML:
Fiddle
You can create a custom filter 'capitalize' and apply it to any string you want:
JavaScript code for filter:
Further to the CSS-only answers, you could always use Twitter Bootstrap: