TemplateRef
class
Represents an embedded template that can be used to instantiate embedded views. To instantiate embedded views based on a template, use the ViewContainerRef
method createEmbeddedView()
.
abstract class TemplateRef<C> { abstract elementRef: ElementRef abstract createEmbeddedView(context: C): EmbeddedViewRef<C> }
See also
Description
Access a TemplateRef
instance by placing a directive on an <ng-template>
element (or directive prefixed with *
). The TemplateRef
for the embedded view is injected into the constructor of the directive, using the TemplateRef
token.
You can also use a Query
to find a TemplateRef
associated with a component or a directive.
Properties
Property | Description |
---|---|
abstract elementRef: ElementRef |
Read-only. The anchor element in the parent view for this embedded view. The data-binding and injection contexts of embedded views created from this Typically new embedded views are attached to the view container of this location, but in advanced use-cases, the view can be attached to a different container while keeping the data-binding and injection context from the original location. |
Methods
createEmbeddedView() | ||
---|---|---|
Creates a view object and attaches it to the view container of the parent view. | ||
|
context | The context for the new view, inherited from the anchor element. |
Returns
EmbeddedViewRef<C>
: The new view object.
© 2010–2019 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://v6.angular.io/api/core/TemplateRef