docs(API): 翻译完了 HttpClientModule

This commit is contained in:
Zhicheng Wang 2018-09-01 21:44:38 +08:00
parent 10ddb2449f
commit 59425a1e5e
2 changed files with 42 additions and 1 deletions

View File

@ -28,7 +28,7 @@
[x] |router/Routes | 2,331 | 0.72
[x] |router/RouterModule | 2,227 | 0.69
[x] |router/Route | 2,223 | 0.69
[ ] |common/http/HttpClientModule | 2,167 | 0.67
[x] |common/http/HttpClientModule | 2,167 | 0.67
[ ] |core/ElementRef | 2,163 | 0.67
[ ] |core/OnInit | 2,136 | 0.66
[ ] |common/UpperCasePipe | 2,078 | 0.65

View File

@ -22,9 +22,15 @@ import {HttpXsrfCookieExtractor, HttpXsrfInterceptor, HttpXsrfTokenExtractor, XS
* An injectable `HttpHandler` that applies multiple interceptors
* to a request before passing it to the given `HttpBackend`.
*
* `HttpHandler` `HttpBackend` 使
*
* The interceptors are loaded lazily from the injector, to allow
* interceptors to themselves inject classes depending indirectly
* on `HttpInterceptingHandler` itself.
*
* 便
* `HttpInterceptingHandler`
*
* @see `HttpInterceptor`
*/
@Injectable()
@ -47,8 +53,11 @@ export class HttpInterceptingHandler implements HttpHandler {
* Constructs an `HttpHandler` that applies interceptors
* to a request before passing it to the given `HttpBackend`.
*
* `HttpHandler` `HttpBackend`
*
* Use as a factory function within `HttpClientModule`.
*
* `HttpClientModule`
*
*/
export function interceptingHandler(
@ -63,9 +72,12 @@ export function interceptingHandler(
/**
* Factory function that determines where to store JSONP callbacks.
*
* JSONP
*
* Ordinarily JSONP callbacks are stored on the `window` object, but this may not exist
* in test environments. In that case, callbacks are stored on an anonymous object instead.
*
* JSONP `window` `window`
*
*/
export function jsonpCallbackContext(): Object {
@ -78,13 +90,18 @@ export function jsonpCallbackContext(): Object {
/**
* An NgModule that adds XSRF protection support to outgoing requests.
*
* NgModule XSRF
*
* For a server that supports a cookie-based XSRF protection system,
* use directly to configure XSRF protection with the correct
* cookie and header names.
*
* Cookie XSRF Cookie XSRF
*
* If no names are supplied, the default cookie name is `XSRF-TOKEN`
* and the default header name is `X-XSRF-TOKEN`.
*
* Cookie `XSRF-TOKEN` `X-XSRF-TOKEN`
*
*/
@NgModule({
@ -99,6 +116,8 @@ export function jsonpCallbackContext(): Object {
export class HttpClientXsrfModule {
/**
* Disable the default XSRF protection.
*
* XSRF
*/
static disable(): ModuleWithProviders {
return {
@ -111,11 +130,22 @@ export class HttpClientXsrfModule {
/**
* Configure XSRF protection.
*
* XSRF
*
* @param options An object that can specify either or both
* cookie name or header name.
*
* Cookie /
*
* - Cookie name default is `XSRF-TOKEN`.
*
* Cookie `XSRF-TOKEN`
*
* - Header name default is `X-XSRF-TOKEN`.
*
* `X-XSRF-TOKEN`
*
*/
static withOptions(options: {
cookieName?: string,
@ -134,14 +164,20 @@ export class HttpClientXsrfModule {
/**
* An NgModule that provides the `HttpClient` and associated services.
*
* NgModule `HttpClient`
*
* Interceptors can be added to the chain behind `HttpClient` by binding them
* to the multiprovider for `HTTP_INTERCEPTORS`.
*
*
* `HTTP_INTERCEPTORS` `HttpClient`
*
*/
@NgModule({
/**
* Optional configuration for XSRF protection.
*
* XSRF
*/
imports: [
HttpClientXsrfModule.withOptions({
@ -151,6 +187,8 @@ export class HttpClientXsrfModule {
],
/**
* The module provides `HttpClient` itself, and supporting services.
*
* `HttpClient`
*/
providers: [
HttpClient,
@ -167,10 +205,13 @@ export class HttpClientModule {
/**
* An NgModule that enables JSONP support in `HttpClient`.
*
* NgModule `HttpClient` JSONP
*
* Without this module, Jsonp requests will reach the backend
* with method JSONP, where they'll be rejected.
*
*
* Jsonp `JSONP`
*/
@NgModule({
providers: [