## URLSearchParams
Map-like representation of url search parameters, based on [URLSearchParams](https://url.spec.whatwg.org/#urlsearchparams) in the url living standard, with several extensions for merging URLSearchParams objects:
setAll()
appendAll()
replaceAll()
This class accepts an optional second parameter of $`QueryEncoder`, which is used to serialize parameters before making a request. By default, QueryEncoder encodes keys and values of parameters using encodeURIComponent, and then un-encodes certain characters that are allowed to be part of the query according to IETF RFC 3986: https://tools.ietf.org/html/rfc3986.
These are the characters that are not encoded: ! $ \' ( ) * + , ; A 9 - . _ ~ ? /
If the set of allowed query characters is not acceptable for a particular backend, QueryEncoder can be subclassed and provided as the 2nd argument to URLSearchParams.
```typescript
import {URLSearchParams, QueryEncoder} from '@angular/http';
class MyQueryEncoder extends QueryEncoder {
encodeKey(k: string): string {
return myEncodingFunction(k);
}
encodeValue(v: string): string {
return myEncodingFunction(v);
}
}
let params = new URLSearchParams('', new MyQueryEncoder());
```
### 类定义
```typescript
class URLSearchParams {
constructor(rawParams?: string, queryEncoder?: QueryEncoder)
paramsMap : Map<string, string[]>
rawParams : string
clone() : URLSearchParams
has(param: string) : boolean
get(param: string) : string
getAll(param: string) : string[]
set(param: string, val: string)
setAll(searchParams: URLSearchParams)
append(param: string, val: string) : void
appendAll(searchParams: URLSearchParams)
replaceAll(searchParams: URLSearchParams)
toString() : string
delete(param: string) : void
}
```
### 属性
- paramsMap : Map<`string`, `string[]`>
- rawParams : string
- clone() : URLSearchParams
- has(param: string) : boolean
- get(param: string) : string
- getAll(param: string) : string[]
- set(param: string, val: string)
- setAll(searchParams: URLSearchParams)
- append(param: string, val: string) : void
- appendAll(searchParams: URLSearchParams)
- replaceAll(searchParams: URLSearchParams)
- toString() : string
- delete(param: string) : void
- 说明
- angular 1.x
- ngModelController
- ngOptions
- ngModelOptions
- lifecycle
- directive
- angular 2
- @angular/forms
- 类
- AbstractControl
- AbstractControlDirective
- AbstractFormGroupDirective
- FormControl
- FormArray
- FormBuilder
- FormGroup
- NgControl
- 接口
- controlValueAccessor
- 指令
- DefaultValueAccessor
- Angular 2 生命周期
- OnInit
- DoCheck
- @angular/router
- 配置
- Routes
- 指令
- RouterOutlet
- RouterLink
- 接口
- ActivatedRoute
- UrlTree
- NavigationExtras
- ActivatedRouteSnapshot
- RouterStateSnapshot
- 类
- UrlSegment
- UrlSegmentGroup
- UrlSerializer
- DefaultUrlSerializer
- Router
- bug记得
- @angular/http
- 类
- Http
- Body
- Response
- ResponseOptions
- Header
- Request
- RequestOptions
- URLSearchParams
- @angular/core
- decorator
- Component-decorator
- animation
- DI
- linker
- TemplateRef
- ElementRef
- EmbeddedViewRef
- ViewRef
- ViewContainerRef
- Query
- ComponentFactory
- ComponentRef
- Renderer
- change_detection
- KeyValueDiffers
- IterableDiffers
- ChangeDetectorRef
- ChangeDetectionStrategy
- Zone
- ngZone
- @angular/common
- 指令
- NgTemplateOutlet
- QueryList
- bootstrap4
- card
- form
- 重点关注博客
- 学习过的文章
- 笔记
- Angular 2 双向绑定
- 将字符串解析成DOM
- rx相关
- operators
- combineLatest
- combineAll
- concat(All, Map, *MapTo)
- 背压(backpressure)
- js事件keycode对应表
- 装饰器
- 有用的代码摘录
- 日期操作
- 数量操作
- 字符操作
- rxjs问题
- 小示例
- h5面试准备
- react
- 开发遇到的问题