Quantcast
Channel: User Simon_Weaver - Stack Overflow
Viewing all articles
Browse latest Browse all 116

Answer by Simon_Weaver for Set null as empty string value for input field

$
0
0

Note: This does work for number fields with a caveat

Currently the NumberValueAccessor (source) sets the value to null when the field is empty.

However, be cautious of this issue https://github.com/angular/angular/issues/55002

If you happen to be setting the input type dynamically:

<input [type]="'number'" />

instead of

<input type="number" />

then the NumberValueAccessor won't get triggered (because it can't match the selector statically at compile time) so the DefaultValueAccessor will apply. In fact in that case ALL numbers will get set as strings to your ngModel / formControl


Viewing all articles
Browse latest Browse all 116

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>