docs: technical review incorporated (#24744)

closes #24744
This commit is contained in:
Judy Bogart
2018-07-18 10:26:59 -07:00
committed by Victor Berchet
parent f1ab394218
commit 7960d1879d
5 changed files with 37 additions and 33 deletions

View File

@ -10,17 +10,17 @@
* Base class for Angular Views, provides change detection functionality. * Base class for Angular Views, provides change detection functionality.
* A change-detection tree collects all views that are to be checked for changes. * A change-detection tree collects all views that are to be checked for changes.
* Use the methods to add and remove views from the tree, initiate change-detection, * Use the methods to add and remove views from the tree, initiate change-detection,
* and exlicitly mark views as _dirty_, meaning that they have changed and need to be rerendered. * and explicitly mark views as _dirty_, meaning that they have changed and need to be rerendered.
* *
* @usageNotes * @usageNotes
* *
* The following examples demonstrate how to modify default change-detection behavior * The following examples demonstrate how to modify default change-detection behavior
* to perform explicit detection when needed. * to perform explicit detection when needed.
* *
* ### Use `markForCheck()` with `checkOnce` strategy * ### Use `markForCheck()` with `CheckOnce` strategy
* *
* The following example sets the `OnPush` change-detection strategy for a component * The following example sets the `OnPush` change-detection strategy for a component
* (`checkOnce`, rather than the default `checkAlways`), then forces a second check * (`CheckOnce`, rather than the default `CheckAlways`), then forces a second check
* after an interval. See [live demo](http://plnkr.co/edit/GC512b?p=preview). * after an interval. See [live demo](http://plnkr.co/edit/GC512b?p=preview).
* *
* <code-example path="core/ts/change_detect/change-detection.ts" * <code-example path="core/ts/change_detect/change-detection.ts"

View File

@ -46,7 +46,7 @@ export interface DirectiveDecorator {
* ### Declaring directives * ### Declaring directives
* *
* Directives are [declarables](guide/glossary#declarable). * Directives are [declarables](guide/glossary#declarable).
* Like component and pipes, they must be declared by an NgModule * They must be declared by an NgModule
* in order to be usable in an app. * in order to be usable in an app.
* *
* A directive must belong to exactly one NgModule. Do not re-declare * A directive must belong to exactly one NgModule. Do not re-declare

View File

@ -100,9 +100,9 @@ export interface DoCheck {
/** /**
* A callback method that performs change-detection, invoked * A callback method that performs change-detection, invoked
* after the default change-detector runs. * after the default change-detector runs.
* @see `KeyValueDiffers` and `IterableDiffers` for implementing * See `KeyValueDiffers` and `IterableDiffers` for implementing
* custom change checking for collections. * custom change checking for collections.
* *
*/ */
ngDoCheck(): void; ngDoCheck(): void;
} }
@ -115,7 +115,7 @@ export interface DoCheck {
* *
* @usageNotes * @usageNotes
* The following snippet shows how a component can implement this interface * The following snippet shows how a component can implement this interface
* to define it own custom clean-up method. * to define its own custom clean-up method.
* *
* {@example core/ts/metadata/lifecycle_hooks_spec.ts region='OnDestroy'} * {@example core/ts/metadata/lifecycle_hooks_spec.ts region='OnDestroy'}
* *

View File

@ -211,19 +211,22 @@ export interface NgModule {
declarations?: Array<Type<any>|any[]>; declarations?: Array<Type<any>|any[]>;
/** /**
* The set of NgModules whose exported directives and pipes * The set of NgModules whose exported [declarables](guide/glossary#declarable)
* are available to templates in this module. * are available to templates in this module.
* *
* @usageNotes * @usageNotes
* *
* A template can exported declarables from any * A template can use exported declarables from any
* imported module, including those that are imported indirectly. * imported module, including those from modules that are imported indirectly
* For example, `CommonModule` imports `BrowserModule`, make the * and re-exported.
* `BrowserModule` exports available wherever `CommonModule` is imported. * For example, `ModuleA` imports `ModuleB`, and also exports
* it, which makes the declarables from `ModuleB` available
* wherever `ModuleA` is imported.
* *
* ### Example * ### Example
* *
* The following example allows MainModule to use `CommonModule`: * The following example allows MainModule to use anthing exported by
* `CommonModule`:
* *
* ```javascript * ```javascript
* @NgModule({ * @NgModule({
@ -241,19 +244,18 @@ export interface NgModule {
* NgModule that can be used in the template of any component that is part of an * NgModule that can be used in the template of any component that is part of an
* NgModule that imports this NgModule. Exported declarations are the module's public API. * NgModule that imports this NgModule. Exported declarations are the module's public API.
* *
* A declarable belongs to one and only one NgModule.
* A module can list another module among its exports, in which case all of that module's
* public declaration are exported.
*
* @usageNotes * @usageNotes
* *
* Declarations are private by default. If this module does not export UserComponent, * Declarations are private by default.
* then only the components within this module can use UserComponent. * If this ModuleA does not export UserComponent, then only the components within this
* ModuleA can use UserComponent.
* *
* Importing a module does not automatically re-export the imported module's imports. * ModuleA can import ModuleB and also export it, making exports from ModuleB
* Module 'B' can't use `ngIf` just because it imported module 'A' which imported `CommonModule`. * available to an NgModule that imports ModuleA.
* Module 'B' must import `CommonModule` itself.
*
* A module can list another module among its exports, in which case all of that module's
* public declaration are exported. Re-export makes module transitivity explicit.
* If Module 'A' re-exports `CommonModule` and Module 'B' imports Module 'A',
* then Module 'B' components can use `ngIf` even though 'B' itself did not import `CommonModule`.
* *
* ### Example * ### Example
* *
@ -279,7 +281,7 @@ export interface NgModule {
* Angular automatically adds components in the module's bootstrap * Angular automatically adds components in the module's bootstrap
* and route definitions into the `entryComponents` list. Use this * and route definitions into the `entryComponents` list. Use this
* option to add components that are bootstrapped * option to add components that are bootstrapped
* using one of the imperative techniques, such as `ViewComponentRef.createComponent()`. * using one of the imperative techniques, such as `ViewContainerRef.createComponent()`.
* *
* @see [Entry Components](guide/entry-components) * @see [Entry Components](guide/entry-components)
*/ */
@ -346,7 +348,7 @@ export const NgModule: NgModuleDecorator = makeDecorator(
* with information about what belongs to the NgModule. * with information about what belongs to the NgModule.
* * The `providers` options configures the NgModule's injector to provide * * The `providers` options configures the NgModule's injector to provide
* dependencies the NgModule members. * dependencies the NgModule members.
* * The `import` and `export` options bring in members from other modules, and make * * The `imports` and `exports` options bring in members from other modules, and make
* this module's members available to others. * this module's members available to others.
*/ */
(type: Type<any>, meta: NgModule) => (R3_COMPILE_NGMODULE || preR3NgModuleCompile)(type, meta)); (type: Type<any>, meta: NgModule) => (R3_COMPILE_NGMODULE || preR3NgModuleCompile)(type, meta));

View File

@ -128,7 +128,7 @@ export interface RendererType2 {
* DOM elements. One of * DOM elements. One of
* - `Emulated` (default): Emulate native scoping of styles. * - `Emulated` (default): Emulate native scoping of styles.
* - `Native`: Use the native encapsulation mechanism of the renderer. * - `Native`: Use the native encapsulation mechanism of the renderer.
* - `ShadowDoc`: Use modern [Shadow * - `ShadowDom`: Use modern [Shadow
* DOM](https://w3c.github.io/webcomponents/spec/shadow/) and * DOM](https://w3c.github.io/webcomponents/spec/shadow/) and
* create a ShadowRoot for component's host element. * create a ShadowRoot for component's host element.
* - `None`: Do not provide any template or style encapsulation. * - `None`: Do not provide any template or style encapsulation.
@ -152,7 +152,7 @@ export interface RendererType2 {
*/ */
export abstract class RendererFactory2 { export abstract class RendererFactory2 {
/** /**
* Implements a custom renderer for a host DOM element. * Creates and initializes a custom renderer for a host DOM element.
* @param hostElement The element to render. * @param hostElement The element to render.
* @param type The base class to implement. * @param type The base class to implement.
* @returns The new custom renderer instance. * @returns The new custom renderer instance.
@ -195,17 +195,17 @@ export enum RendererStyleFlags2 {
* *
* Create your custom renderer using `RendererFactory2`. * Create your custom renderer using `RendererFactory2`.
* *
* Use a custom renderer to bypass Angular's templating and make custom UI changes that can't be * Use a custom renderer to bypass Angular's templating and
* expressed declaratively. * make custom UI changes that can't be expressed declaratively.
* For example if you need to set a property or an attribute whose name is * For example if you need to set a property or an attribute whose name is
* not statically known, use the `setElementProperty()` or * not statically known, use the `setProperty()` or
* `setElementAttribute()` method. * `setAttribute()` method.
* *
* @experimental * @experimental
*/ */
export abstract class Renderer2 { export abstract class Renderer2 {
/** /**
* Implement this callback to store arbitrary developer-defined data on a renderer instance, * Use to store arbitrary developer-defined data on a renderer instance,
* as an object containing key-value pairs. * as an object containing key-value pairs.
* This is useful for renderers that delegate to other renderers. * This is useful for renderers that delegate to other renderers.
*/ */
@ -262,7 +262,8 @@ export abstract class Renderer2 {
*/ */
abstract removeChild(parent: any, oldChild: any): void; abstract removeChild(parent: any, oldChild: any): void;
/** /**
* Implement this callback to get the root element of a DOM element. * Implement this callback to prepare an element to be bootstrapped
* as a root element, and return the element instance.
* @param selectorOrNode The DOM element. * @param selectorOrNode The DOM element.
* @returns The root element. * @returns The root element.
*/ */
@ -355,6 +356,7 @@ export abstract class Renderer2 {
* DOM element. * DOM element.
* @param eventName The event to listen for. * @param eventName The event to listen for.
* @param callback A handler function to invoke when the event occurs. * @param callback A handler function to invoke when the event occurs.
* @returns An "unlisten" function for disposing of this handler.
*/ */
abstract listen( abstract listen(
target: 'window'|'document'|'body'|any, eventName: string, target: 'window'|'document'|'body'|any, eventName: string,