I have an interface where one of its properties can either be a number or null. However, whenever I set the property to null through a select tag and send the object to the API it sends to the API "null" string instead of null. Which is causing a validation error in the API.
Interface:
export interface IAddress{
email: string;
areaId: number | null;
}
HTML:
<select name="area" id="area" [(ngModel)]="address.areaId">
<option selected [value]="null">-- Area --</option>
<option *ngFor="let area of area" [value]="area.id">{{area.name}}</option>
</select>
ts:
this.addressService.addOrUpdate(this.address).subscribe({
next: () => do something....
})