Directive to upper case input fields

后端 未结 5 894
北荒
北荒 2021-01-03 06:04

I want to use a directive to transform all input data to uppercase. To achieve that, I create this custom directive :

@Directive({
  selector: \'[appToUpperC         


        
5条回答
  •  盖世英雄少女心
    2021-01-03 07:05

    Basically when you modify the value from imperative code, it becomes difficult manage position of cursor. When you re-write value input value, it throws cursor at the start of input.

    I'd recommend you to go for CSS way. More cleaner

    [my-attribute] input { text-transform: uppercase; }
    

提交回复
热议问题