I have some categories in a formcontrol, I send them in an array of string like this:
[1,4,6]
And that is my actual code:
May be this is what you are looking for
component file:
import { Component } from '@angular/core';
import { HttpParams } from '@angular/common/http';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
data = [
{id:'_', title:'_', content:'_'},
....,
....
];
mainArr:any = [];
constructor(){}
getCategory(item){
this.mainArr.push({title:item.title,content:item.content,categoryId:item.id});
console.log('mainArr',this.mainArr);
let requestOptions = {
params: new HttpParams()
.append('data', this.mainArr),
withCredentials: true
}
console.log('requestOptions',requestOptions);
}
}