我已经定义了一个简单的select
绑定到这样的变量:
<select id="client" name="client" [(ngModel)]="order.clientId">
<option *ngFor="let client of clients" [value]="client.id">
{{ client.name }}
</option>
</select>
而clients
是一个简单的类,具有数字id
值:
export class NameAndId {
id: number;
name: string;
constructor(id: number, name: string) {
this.id = id;
this.name = name;
}
}
因此,我希望该值是数字,而不是字符串。 order.clientId
也定义为数字。但是,当我像这样通过order
发布调用传递HttpClient
对象时,它会将值编码为字符串:
return this.http.post<HttpResponse<any>>(this.baseUrl, order, {observe: 'response'});
为什么它不显示为数字值?