docs(API): 翻译完了 ViewContainerRef

This commit is contained in:
Zhicheng Wang 2018-09-03 08:54:32 +08:00
parent 3fc7bb2ab4
commit 6292866c98
2 changed files with 58 additions and 1 deletions

View File

@ -42,7 +42,7 @@
[ ] | core/Renderer2 | 0.49 [ ] | core/Renderer2 | 0.49
[x] | core/HostListener | 0.47 [x] | core/HostListener | 0.47
[x] | common/AsyncPipe | 0.45 [x] | common/AsyncPipe | 0.45
[ ] | core/ViewContainerRef | 0.42 [x] | core/ViewContainerRef | 0.42
[ ] | common/NgTemplateOutlet | 0.42 [ ] | common/NgTemplateOutlet | 0.42
[ ] | common/Location | 0.41 [ ] | common/Location | 0.41
[ ] | platform-browser/BrowserModule | 0.40 [ ] | platform-browser/BrowserModule | 0.40

View File

@ -17,24 +17,39 @@ import {EmbeddedViewRef, ViewRef} from './view_ref';
/** /**
* Represents a container where one or more Views can be attached. * Represents a container where one or more Views can be attached.
* *
*
*
* The container can contain two kinds of Views. Host Views, created by instantiating a * The container can contain two kinds of Views. Host Views, created by instantiating a
* {@link Component} via {@link #createComponent}, and Embedded Views, created by instantiating an * {@link Component} via {@link #createComponent}, and Embedded Views, created by instantiating an
* {@link TemplateRef Embedded Template} via {@link #createEmbeddedView}. * {@link TemplateRef Embedded Template} via {@link #createEmbeddedView}.
* *
* 宿 {@link #createComponent} {@link Component}
* {@link #createEmbeddedView} {@link TemplateRef }
*
* The location of the View Container within the containing View is specified by the Anchor * The location of the View Container within the containing View is specified by the Anchor
* `element`. Each View Container can have only one Anchor Element and each Anchor Element can only * `element`. Each View Container can have only one Anchor Element and each Anchor Element can only
* have a single View Container. * have a single View Container.
* *
* ViewContainer `element`
* ViewContainer ViewContainer
*
* Root elements of Views attached to this container become siblings of the Anchor Element in * Root elements of Views attached to this container become siblings of the Anchor Element in
* the Rendered View. * the Rendered View.
* *
*
*
* To access a `ViewContainerRef` of an Element, you can either place a {@link Directive} injected * To access a `ViewContainerRef` of an Element, you can either place a {@link Directive} injected
* with `ViewContainerRef` on the Element, or you obtain it via a {@link ViewChild} query. * with `ViewContainerRef` on the Element, or you obtain it via a {@link ViewChild} query.
* *
* 访 `ViewContainerRef` {@link Directive} `ViewContainerRef`
* {@link ViewChild}
*
*/ */
export abstract class ViewContainerRef { export abstract class ViewContainerRef {
/** /**
* Anchor element that specifies the location of this container in the containing View. * Anchor element that specifies the location of this container in the containing View.
*
*
* <!-- TODO: rename to anchorElement --> * <!-- TODO: rename to anchorElement -->
*/ */
abstract get element(): ElementRef; abstract get element(): ElementRef;
@ -45,16 +60,22 @@ export abstract class ViewContainerRef {
/** /**
* Destroys all Views in this container. * Destroys all Views in this container.
*
*
*/ */
abstract clear(): void; abstract clear(): void;
/** /**
* Returns the {@link ViewRef} for the View located in this container at the specified index. * Returns the {@link ViewRef} for the View located in this container at the specified index.
*
* {@link ViewRef}
*/ */
abstract get(index: number): ViewRef|null; abstract get(index: number): ViewRef|null;
/** /**
* Returns the number of Views currently attached to this container. * Returns the number of Views currently attached to this container.
*
*
*/ */
abstract get length(): number; abstract get length(): number;
@ -62,9 +83,15 @@ export abstract class ViewContainerRef {
* Instantiates an Embedded View based on the {@link TemplateRef `templateRef`} and inserts it * Instantiates an Embedded View based on the {@link TemplateRef `templateRef`} and inserts it
* into this container at the specified `index`. * into this container at the specified `index`.
* *
* {@link TemplateRef `templateRef`} `index`
*
* If `index` is not specified, the new View will be inserted as the last View in the container. * If `index` is not specified, the new View will be inserted as the last View in the container.
* *
* `index`
*
* Returns the {@link ViewRef} for the newly created View. * Returns the {@link ViewRef} for the newly created View.
*
* {@link ViewRef}
*/ */
abstract createEmbeddedView<C>(templateRef: TemplateRef<C>, context?: C, index?: number): abstract createEmbeddedView<C>(templateRef: TemplateRef<C>, context?: C, index?: number):
EmbeddedViewRef<C>; EmbeddedViewRef<C>;
@ -73,14 +100,24 @@ export abstract class ViewContainerRef {
* Instantiates a single {@link Component} and inserts its Host View into this container at the * Instantiates a single {@link Component} and inserts its Host View into this container at the
* specified `index`. * specified `index`.
* *
* {@link Component} 宿 `index`
*
* The component is instantiated using its {@link ComponentFactory} which can be obtained via * The component is instantiated using its {@link ComponentFactory} which can be obtained via
* {@link ComponentFactoryResolver#resolveComponentFactory resolveComponentFactory}. * {@link ComponentFactoryResolver#resolveComponentFactory resolveComponentFactory}.
* *
* 使 {@link ComponentFactory} `ComponentFactory` {@link ComponentFactoryResolver#resolveComponentFactory resolveComponentFactory}
*
* If `index` is not specified, the new View will be inserted as the last View in the container. * If `index` is not specified, the new View will be inserted as the last View in the container.
* *
* `index`
*
* You can optionally specify the {@link Injector} that will be used as parent for the Component. * You can optionally specify the {@link Injector} that will be used as parent for the Component.
* *
* {@link Injector}
*
* Returns the {@link ComponentRef} of the Host View created for the newly instantiated Component. * Returns the {@link ComponentRef} of the Host View created for the newly instantiated Component.
*
* 宿 {@link ComponentRef}
*/ */
abstract createComponent<C>( abstract createComponent<C>(
componentFactory: ComponentFactory<C>, index?: number, injector?: Injector, componentFactory: ComponentFactory<C>, index?: number, injector?: Injector,
@ -89,36 +126,56 @@ export abstract class ViewContainerRef {
/** /**
* Inserts a View identified by a {@link ViewRef} into the container at the specified `index`. * Inserts a View identified by a {@link ViewRef} into the container at the specified `index`.
* *
* {@link ViewRef} `index`
*
* If `index` is not specified, the new View will be inserted as the last View in the container. * If `index` is not specified, the new View will be inserted as the last View in the container.
* *
* `index`
*
* Returns the inserted {@link ViewRef}. * Returns the inserted {@link ViewRef}.
*
* {@link ViewRef}
*/ */
abstract insert(viewRef: ViewRef, index?: number): ViewRef; abstract insert(viewRef: ViewRef, index?: number): ViewRef;
/** /**
* Moves a View identified by a {@link ViewRef} into the container at the specified `index`. * Moves a View identified by a {@link ViewRef} into the container at the specified `index`.
* *
* {@link ViewRef} `index`
*
* Returns the inserted {@link ViewRef}. * Returns the inserted {@link ViewRef}.
*
* {@link ViewRef}
*/ */
abstract move(viewRef: ViewRef, currentIndex: number): ViewRef; abstract move(viewRef: ViewRef, currentIndex: number): ViewRef;
/** /**
* Returns the index of the View, specified via {@link ViewRef}, within the current container or * Returns the index of the View, specified via {@link ViewRef}, within the current container or
* `-1` if this container doesn't contain the View. * `-1` if this container doesn't contain the View.
*
* `-1`
*/ */
abstract indexOf(viewRef: ViewRef): number; abstract indexOf(viewRef: ViewRef): number;
/** /**
* Destroys a View attached to this container at the specified `index`. * Destroys a View attached to this container at the specified `index`.
* *
* `index`
*
* If `index` is not specified, the last View in the container will be removed. * If `index` is not specified, the last View in the container will be removed.
*
* `index`
*/ */
abstract remove(index?: number): void; abstract remove(index?: number): void;
/** /**
* Use along with {@link #insert} to move a View within the current container. * Use along with {@link #insert} to move a View within the current container.
* *
* {@link #insert} 使
*
* If the `index` param is omitted, the last {@link ViewRef} is detached. * If the `index` param is omitted, the last {@link ViewRef} is detached.
*
* `index` {@link ViewRef}
*/ */
abstract detach(index?: number): ViewRef|null; abstract detach(index?: number): ViewRef|null;
} }