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
[x] | core/HostListener | 0.47
[x] | common/AsyncPipe | 0.45
[ ] | core/ViewContainerRef | 0.42
[x] | core/ViewContainerRef | 0.42
[ ] | common/NgTemplateOutlet | 0.42
[ ] | common/Location | 0.41
[ ] | 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.
*
*
*
* 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 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
* `element`. Each View Container can have only one Anchor Element and each Anchor Element can only
* have a single View Container.
*
* ViewContainer `element`
* ViewContainer ViewContainer
*
* Root elements of Views attached to this container become siblings of the Anchor Element in
* the Rendered View.
*
*
*
* 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.
*
* 访 `ViewContainerRef` {@link Directive} `ViewContainerRef`
* {@link ViewChild}
*
*/
export abstract class ViewContainerRef {
/**
* Anchor element that specifies the location of this container in the containing View.
*
*
* <!-- TODO: rename to anchorElement -->
*/
abstract get element(): ElementRef;
@ -45,16 +60,22 @@ export abstract class ViewContainerRef {
/**
* Destroys all Views in this container.
*
*
*/
abstract clear(): void;
/**
* Returns the {@link ViewRef} for the View located in this container at the specified index.
*
* {@link ViewRef}
*/
abstract get(index: number): ViewRef|null;
/**
* Returns the number of Views currently attached to this container.
*
*
*/
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
* 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.
*
* `index`
*
* Returns the {@link ViewRef} for the newly created View.
*
* {@link ViewRef}
*/
abstract createEmbeddedView<C>(templateRef: TemplateRef<C>, context?: C, index?: number):
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
* specified `index`.
*
* {@link Component} 宿 `index`
*
* The component is instantiated using its {@link ComponentFactory} which can be obtained via
* {@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.
*
* `index`
*
* 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.
*
* 宿 {@link ComponentRef}
*/
abstract createComponent<C>(
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`.
*
* {@link ViewRef} `index`
*
* If `index` is not specified, the new View will be inserted as the last View in the container.
*
* `index`
*
* Returns the inserted {@link ViewRef}.
*
* {@link ViewRef}
*/
abstract insert(viewRef: ViewRef, index?: number): ViewRef;
/**
* Moves a View identified by a {@link ViewRef} into the container at the specified `index`.
*
* {@link ViewRef} `index`
*
* Returns the inserted {@link ViewRef}.
*
* {@link ViewRef}
*/
abstract move(viewRef: ViewRef, currentIndex: number): ViewRef;
/**
* 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`
*/
abstract indexOf(viewRef: ViewRef): number;
/**
* 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.
*
* `index`
*/
abstract remove(index?: number): void;
/**
* 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.
*
* `index` {@link ViewRef}
*/
abstract detach(index?: number): ViewRef|null;
}