Reputation: 10345
I've defined a simple select
bound to a variable like so:
<select id="client" name="client" [(ngModel)]="order.clientId">
<option *ngFor="let client of clients" [value]="client.id">
{{ client.name }}
</option>
</select>
and the clients
is a simple class with a numeric id
value:
export class NameAndId {
id: number;
name: string;
constructor(id: number, name: string) {
this.id = id;
this.name = name;
}
}
So I would expect that the value is a number, not a string. And the order.clientId
is also defined as a number. However, when I pass the order
object through an HttpClient
post call like so, it's encoding the value as a string:
return this.http.post<HttpResponse<any>>(this.baseUrl, order, {observe: 'response'});
Why isn't it appearing as a numeric value?
Upvotes: 2
Views: 2203