EmbeddedViewRef class

An embedded Angular view that can be created and destroyed dynamically.

An embedded view is instantiated from a TemplateRef, and can be inserted into a ViewContainerRef.

This is the public interface which only generated embedded views implement. It adds additional functionality to ViewRef that is specific to embedded views, such as manipulating template local variables.


Consider the following template:

  <li *ngFor="let item of items">{{item}}</li>

Note the *-binding is just sugar for the following:

  <template ngFor let-item [ngForOf]="items">
    <!-- TemplateRef -->

In this example, item is a template input variable that is local to each embedded view created from this template.

Given items = ['First', 'Second'], this example would render:

  <!-- EmbeddedViewRef -->
  <!-- EmbeddedViewRef -->

Note how ngFor has used the TemplateRef to create an EmbeddedViewRef for each item.

Implemented types




destroyed bool
Whether this view has been destroyed.
read-only, inherited
hashCode int
The hash code for this object. [...]
read-only, inherited
rootNodes List<Node>
This view's root DOM nodes.
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited


destroy() → void
Detaches this view and destroys all of its associated state.
hasLocal(String name) bool
Checks whether this view has a local variable called name.
markForCheck() → void
Marks this view to be change detected in an "OnPush" context.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
onDestroy(void callback()) → void
Registers a callback to invoke when this view is destroyed.
setLocal(String name, dynamic value) → void
Sets the value of local variable called name in this view. [...]
toString() String
A string representation of this object. [...]


operator ==(Object other) bool
The equality operator. [...]