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 Component via #createComponent, and Embedded Views, created by instantiating an TemplateRef Embedded Template via #createEmbeddedView.

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.

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 Directive injected with ViewContainerRef on the Element, or you obtain it via a ViewChild query.

Constructors

ViewContainerRef(AppElement _element)

Properties

element ElementRef

Anchor element that specifies the location of this container in the containing View.

read-only
hashCode → int

Get a hash code for this object.

read-only, inherited
injector Injector

read-only
length → num

Returns the number of Views currently attached to this container.

read-only
parentInjector Injector

read-only
runtimeType → Type

A representation of the runtime type of the object.

read-only, inherited

Operators

operator ==(other) → bool

The equality operator.

inherited

Methods

clear() → void

Destroys all Views in this container.

createComponent(ComponentFactory componentFactory, [ num index = -1, Injector injector = null, List<List> projectableNodes = null ]) ComponentRef

Instantiates a single Component and inserts its Host View into this container at the specified index.

createEmbeddedView(TemplateRef templateRef) EmbeddedViewRef

Instantiates an Embedded View based on the TemplateRef `templateRef` and appends it into this container.

detach([num index = -1 ]) ViewRef

Use along with #insert to move a View within the current container.

get(num index) EmbeddedViewRef

Returns the ViewRef for the View located in this container at the specified index.

indexOf(ViewRef viewRef) → num

Returns the index of the View, specified via ViewRef, within the current container or -1 if this container doesn't contain the View.

insert(ViewRef viewRef, [ num index = -1 ]) ViewRef

Inserts a View identified by a ViewRef into the container.

insertEmbeddedView(TemplateRef templateRef, int index) EmbeddedViewRef

Instantiates an Embedded View based on the TemplateRef `templateRef` and inserts it into this container at the specified index.

move(ViewRef viewRef, int currentIndex) ViewRef

noSuchMethod(Invocation invocation) → dynamic

Invoked when a non-existent method or property is accessed.

inherited
remove([num index = -1 ]) → void

Destroys a View attached to this container at the specified index.

toString() → String

Returns a string representation of this object.

inherited