Web API 是否从角度获取 NULL 值作为"NULL"?



我有一个webAPI文件&角度文件,空值从该角度文件传递到web API。在传递空值的同时,它反映为"0";NULL";。我的API控制器TS文件如下

getOfficeOrganizationalRoles(OfficeSelected,gbobranchname): ng.IHttpPromise<SelectItem[]> {
//return this.http.get(this.apiEndpoints.baseUrl + this.apiEndpoints.getOfficeOrganizationalRoles + "?officeIds=" + OfficeSelected + "&gbobranch=" + gbobranchname);
return this.http.get(this.apiEndpoints.baseUrl + this.apiEndpoints.getOfficeOrganizationalRoles + "?officeIds=" + OfficeSelected);
};

我怎样才能用"quot;已删除。我需要OfficeIds&gbobbranch。

试着这样做,这样如果参数为空,就不必传递参数

getOfficeOrganizationalRoles(OfficeSelected, gbobranchname): ng.IHttpPromise<SelectItem[]> {
const params: any = {};
if (OfficeSelected) {
params.officeIds = OfficeSelected;
}
if (gbobranchname) {
params.gbobranch = gbobranchname;
}
return this.httpClient.get(this.apiEndpoints.baseUrl + this.apiEndpoints.getOfficeOrganizationalRoles, { params });
};

最新更新