相关疑难解决方法(0)

多个对象进入HttpParams

我在formcontrol中有一些类别,我将它们发送到一个字符串数组中,如下所示:

[1,4,6]

那是我的实际代码:

let categoryIds = new Array<String>()
this.selectedCategories.forEach((value: string, key: string) =>
  categoryIds.push(key))

let requestOptions = {
    params: new HttpParams()
        .set('title', this.createNewForm.controls['title'].value)
        .append('content', this.createNewForm.controls['content'].value)
        .append('categoryids', categoryIds.toString()),              
    withCredentials: true
}
Run Code Online (Sandbox Code Playgroud)

但是我希望将它们作为一个对象数组发送,使用旧版本的角度Http我能够对该对象做一个foreach并追加每个类别.但我不知道如何获得每个类别,并使每个类别附加到params.我需要这样:

...的categoryId = 1&的categoryId = 4&的categoryId = 6 ...

typescript angular angular-httpclient

5
推荐指数
2
解决办法
1万
查看次数

标签 统计

angular ×1

angular-httpclient ×1

typescript ×1