0

Whenever I try to set HttpParams it's like:

let params = new HttpParams()
    .set('someKey', this.key)

but my API URL looks like this:

/api/something/99999/item

So how to set this.key like this which is 99999?

4

2 回答 2

0

据我了解,您不需要HttpParams.

您可以像这样直接传递this.key给 url:

const url = `api/something/${this.key}/item`;

在使用 url 进行 http 调用之后。

于 2018-12-03T14:40:21.973 回答
0

只需绑定到没有 HttpParams 的 url

this.http.get('/api/something/' + this.key + '/item')
于 2018-12-03T14:40:38.480 回答