docs: improve documentation on how to pass a stringified parameter list to HttpClient (#41010)

Fixes #40618

PR Close #41010
This commit is contained in:
Chris 2021-02-26 14:52:14 +07:00 committed by Andrew Kushnir
parent 9ae0faa00a
commit ad40fcae7a
2 changed files with 16 additions and 0 deletions

View File

@ -74,6 +74,14 @@ function addBody<T>(
* return this.httpClient.request('GET', this.heroesUrl, {responseType:'json', params});
* }
* ```
*
* Alternatively, the parameter string can be used without invoking HttpParams
* by directly joining to the URL.
* ```
* this.httpClient.request('GET', this.heroesUrl + '?' + 'name=term', {responseType:'json'});
* ```
*
*
* ### JSONP Example
* ```
* requestJsonp(url, callback = 'callback') {
@ -92,6 +100,7 @@ function addBody<T>(
* ```
*
* @see [HTTP Guide](guide/http)
* @see [HTTP Request](api/common/http/HttpRequest)
*
* @publicApi
*/

View File

@ -119,6 +119,13 @@ export class HttpRequest<T> {
/**
* Outgoing URL parameters.
*
* To pass a string representation of HTTP parameters in the URL-query-string format,
* the `HttpParamsOptions`' `fromString` may be used. For example:
*
* ```
* new HttpParams({fromString: 'angular=awesome'})
* ```
*/
// TODO(issue/24571): remove '!'.
readonly params!: HttpParams;