khashayar / ng-trim-value-accessor

Angular's (missing) trim accessor to automatically trim values of input fields
MIT License
53 stars 19 forks source link

Radio buttons miss value with this directive #2

Closed artgladun closed 7 years ago

artgladun commented 7 years ago

I've improved your selector to ignore radio buttons as well. Without it, radios miss values after init.

    input:not([type=radio])[formControlName],
    input:not([type=checkbox])[formControlName],
    textarea[formControlName],
    input:not([type=radio])[formControl],
    input:not([type=checkbox])[formControl],
    textarea[formControl],
    input:not([type=radio])[ngModel],
    input:not([type=checkbox])[ngModel],
    textarea[ngModel],
    [ngDefaultControl]
dmitryshunkov commented 7 years ago

@artgladun, I think, your selector should look like this:

input:not([type=radio]):not([type=checkbox])[formControlName],
textarea[formControlName],
input:not([type=radio]):not([type=checkbox])[formControl],
textarea[formControl],
input:not([type=radio]):not([type=checkbox])[ngModel],
textarea[ngModel],
[ngDefaultControl]

(see https://stackoverflow.com/questions/2797091)

artgladun commented 7 years ago

You'are right. Please also consider removing password input out of this selector.

khashayar commented 7 years ago

Thanks for reporting it... It's fixed in release v0.0.6