diff --git a/packages/common/http/src/module.ts b/packages/common/http/src/module.ts
index 83a9fbfc94..feceb505e0 100644
--- a/packages/common/http/src/module.ts
+++ b/packages/common/http/src/module.ts
@@ -19,12 +19,13 @@ import {BrowserXhr, HttpXhrBackend, XhrFactory} from './xhr';
import {HttpXsrfCookieExtractor, HttpXsrfInterceptor, HttpXsrfTokenExtractor, XSRF_COOKIE_NAME, XSRF_HEADER_NAME} from './xsrf';
/**
- * An `HttpHandler` that applies a bunch of `HttpInterceptor`s
+ * An injectable `HttpHandler` that applies multiple interceptors
* to a request before passing it to the given `HttpBackend`.
*
* The interceptors are loaded lazily from the injector, to allow
* interceptors to themselves inject classes depending indirectly
* on `HttpInterceptingHandler` itself.
+ * @see `HttpInterceptor`
*/
@Injectable()
export class HttpInterceptingHandler implements HttpHandler {
@@ -42,6 +43,23 @@ export class HttpInterceptingHandler implements HttpHandler {
}
}
+/**
+ * Constructs an `HttpHandler` that applies interceptors
+ * to a request before passing it to the given `HttpBackend`.
+ *
+ * Use as a factory function within `HttpClientModule`.
+ *
+ *
+ */
+export function interceptingHandler(
+ backend: HttpBackend, interceptors: HttpInterceptor[] | null = []): HttpHandler {
+ if (!interceptors) {
+ return backend;
+ }
+ return interceptors.reduceRight(
+ (next, interceptor) => new HttpInterceptorHandler(next, interceptor), backend);
+}
+
/**
* Factory function that determines where to store JSONP callbacks.
*
@@ -58,14 +76,14 @@ export function jsonpCallbackContext(): Object {
}
/**
- * `NgModule` which adds XSRF protection support to outgoing requests.
+ * An NgModule that adds XSRF protection support to outgoing requests.
*
- * Provided the server supports a cookie-based XSRF protection system, this
- * module can be used directly to configure XSRF protection with the correct
+ * For a server that supports a cookie-based XSRF protection system,
+ * use directly to configure XSRF protection with the correct
* cookie and header names.
*
- * If no such names are provided, the default is to use `X-XSRF-TOKEN` for
- * the header name and `XSRF-TOKEN` for the cookie name.
+ * If no names are supplied, the default cookie name is `XSRF-TOKEN`
+ * and the default header name is `X-XSRF-TOKEN`.
*
*
*/
@@ -92,8 +110,12 @@ export class HttpClientXsrfModule {
}
/**
- * Configure XSRF protection to use the given cookie name or header name,
- * or the default names (as described above) if not provided.
+ * Configure XSRF protection.
+ * @param options An object that can specify either or both
+ * cookie name or header name.
+ * - Cookie name default is `XSRF-TOKEN`.
+ * - Header name default is `X-XSRF-TOKEN`.
+ *
*/
static withOptions(options: {
cookieName?: string,
@@ -110,7 +132,7 @@ export class HttpClientXsrfModule {
}
/**
- * `NgModule` which provides the `HttpClient` and associated services.
+ * An NgModule that provides the `HttpClient` and associated services.
*
* Interceptors can be added to the chain behind `HttpClient` by binding them
* to the multiprovider for `HTTP_INTERCEPTORS`.
@@ -118,12 +140,18 @@ export class HttpClientXsrfModule {
*
*/
@NgModule({
+ /**
+ * Optional configuration for XSRF protection.
+ */
imports: [
HttpClientXsrfModule.withOptions({
cookieName: 'XSRF-TOKEN',
headerName: 'X-XSRF-TOKEN',
}),
],
+ /**
+ * The module provides `HttpClient` itself, and supporting services.
+ */
providers: [
HttpClient,
{provide: HttpHandler, useClass: HttpInterceptingHandler},
@@ -137,7 +165,7 @@ export class HttpClientModule {
}
/**
- * `NgModule` which enables JSONP support in `HttpClient`.
+ * An NgModule that enables JSONP support in `HttpClient`.
*
* Without this module, Jsonp requests will reach the backend
* with method JSONP, where they'll be rejected.
diff --git a/packages/core/src/metadata/directives.ts b/packages/core/src/metadata/directives.ts
index 61e3ef7cfa..4a5692cbb4 100644
--- a/packages/core/src/metadata/directives.ts
+++ b/packages/core/src/metadata/directives.ts
@@ -137,17 +137,6 @@ export interface Directive {
* bankName: string;
* id: string;
*
- * // this property is not bound, and won't be automatically updated by Angular
- * normalizedBankName: string;
- * }
- *
- * @Component({
- * selector: 'app',
- * template: `
- *