I have set up a basic select
connected to a variable like this:
<select id="client" name="client" [(ngModel)]="order.clientId">
<option *ngFor="let client of clients" [value]="client.id">
{{ client.name }}
</option>
</select>
The clients
class has a numeric id
value:
export class NameAndId {
id: number;
name: string;
constructor(id: number, name: string) {
this.id = id;
this.name = name;
}
}
I would expect the value to be numeric since both the value in the clients
class and order.clientId
are defined as numbers. However, when passing the order
object through an HttpClient
post call like this, it is being encoded as a string:
return this.http.post<HttpResponse<any>>(this.baseUrl, order, {observe: 'response'});
Why is it not showing as a numeric value?