With this select below the default value of null is working when I first load it and then when I change it's value to some other option, but then if I change it back to the default "None selected" and submit the value is converted to a string "null", so when I try and pass it to my controller where the controllers property is a int? (nullable int) it throws an exception because I'm try to pass in a string.
Is there a way to keep it as a null and not a string or should I be using all string values for the values?
FYI - I don't wan't to do any JS post submit processing to check the value
<div class="form-group col-md-4">
<label for="processOptionId">Claim Process</label>
<select class="form-control" [(ngModel)]="claim.data.processOptionId" name="processOptionId">
<option value=null>None selected</option>
<option *ngFor="let processOption of processOptionList" [value]="processOption.code">{{processOption.name}}</option>
</select>
</div>
You should bind the null option value with [ngValue]:
<option [ngValue]="null">None selected</option>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With