## ResponseOptions
Creates a response options object to be optionally provided when instantiating a `Response`.
This class is based on the ResponseInit description in the Fetch Spec.
All values are null by default. Typical defaults can be found in the `BaseResponseOptions` class, which sub-classes `ResponseOptions`.
This class may be used in tests to build `Responses` for mock responses (see `MockBackend`).
示例:
```typescript
import {ResponseOptions, Response} from '@angular/http';
var options = new ResponseOptions({
body: '{"name":"Jeff"}'
});
var res = new Response(options);
console.log('res.json():', res.json()); // Object {name: "Jeff"}
```
### 類定義
```typescript
class ResponseOptions {
constructor({body, status, headers, statusText, type, url}?: ResponseOptionsArgs)
body : string|Object|ArrayBuffer|Blob
status : number
headers : Headers
url : string
merge(options?: ResponseOptionsArgs) : ResponseOptions
}
```
### 屬性
- body : `string` | `Object` | `ArrayBuffer` | `Blob`
表示`Response`響應體的數據類型:String, Object, ArrayBuffer or Blob
- status : `number` 狀態碼
- headers : `Headers` 請求體頭部
- url : `string`
- merge(options?: `ResponseOptionsArgs`) : `ResponseOptions`
Creates a copy of the ResponseOptions instance, using the optional input as values to override existing values. This method will not change the values of the instance on which it is being called.
This may be useful when sharing a base ResponseOptions object inside tests, where certain properties may
```typescript
import {ResponseOptions, Response} from '@angular/http';
var options = new ResponseOptions({
body: {name: 'Jeff'}
});
var res = new Response(options.merge({
url: 'https://google.com'
}));
console.log('options.url:', options.url); // null
console.log('res.json():', res.json()); // Object {name: "Jeff"}
console.log('res.url:', res.url); // https://google.com
```
- 說明
- 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
- 開發遇到的問題