angular - 如何在 Angular 6 api 调用中将数组对象作为参数传递
问题描述
在下面的代码中,companyId
是一个对象数组,我想将其作为 API 调用的参数传递,我该怎么做?
getItems(): void {
this.urlcall()
.subscribe(
restItems => {
this.vehicle = restItems;
console.log('Vehicle Data=',this.vehicle);
});
}
urlcall() {
return this.http.get<any[]>(this.Url, { responseType : 'json',params : this.params ,headers : this.httpHeaders } )
.pipe(map(data => data));
}
public params = new HttpParams()
.set('CompanyID', this.companyID )
.set('vehicleId', '23')
.set('currentOdometer', this.cOdometer);
public httpHeaders = new HttpHeaders()
.set('Accept','application/x-www-form-urlencoded');
解决方案
推荐阅读
- mysql - 原始 SQL 到 laravel 查询构建器
- tensorflow - 文本嵌入层后池化层的目的
- reactjs - 使用反应钩子重新渲染问题
- r - 相邻顶点表格 igraph 不能处理传入的关系?
- c# - SqlParameterCollection 只接受非空参数类型对象
- c++ - C++:从文件读取时如何显示最后五个名称/行?
- core-data - 在 swiftUI 中更改谓词时重新加载 FetchedResults
- azure - ADF 复制数据活动 - 在插入 SQL 数据库之前检查重复记录
- jenkins - 使用作业 dsl 设置 Jenkins 参数化调度程序插件
- ios - 通过 Whatsapp 的共享表发送图像在 Swift 中不起作用