Experimental Class
Class Overview
1 2 3 4 5 | class BaseRequestOptions { constructor() } |
Class Description
Subclass of RequestOptions
, with default values.
Default values:
- method: RequestMethod.Get
- headers: empty
Headers
object
This class could be extended and bound to the RequestOptions
class when configuring an Injector
, in order to override the default options used by Http
to create and send Requests.
Example (live demo)
1 2 3 4 5 6 7 8 9 10 | import {provide} from '@angular/core' ; import {bootstrap} from '@angular/platform-browser/browser' ; import {HTTP_PROVIDERS, Http, BaseRequestOptions, RequestOptions} from '@angular/http' ; import {App} from './myapp' ; class MyOptions extends BaseRequestOptions { search: string = 'coreTeam=true' ; } bootstrap(App, [HTTP_PROVIDERS, {provide: RequestOptions, useClass: MyOptions}]); |
The options could also be extended when manually creating a Request
object.
Example (live demo)
1 2 3 4 5 6 7 8 9 10 | import {BaseRequestOptions, Request, RequestMethod} from '@angular/http' ; var options = new BaseRequestOptions(); var req = new Request(options.merge({ method: RequestMethod.Post, })); console.log( 'req.method:' , RequestMethod[req.method]); // Post console.log( 'options.url:' , options.url); // null |
Annotations
@Injectable()
Constructor
constructor()
exported from @angular/http/index, defined in @angular/http/src/base_request_options.ts
Please login to continue.