如何在angular 6 api调用中将数组对象作为参数传递

时间:2018-12-03 10:02:28

标签: angular typescript

在下面的代码中,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');

0 个答案:

没有答案