NgTemplateOutlet class

Inserts an embedded view, created from a TemplateRef.

Examples

@Component(
  selector: 'example',
  template: '''
    <template #text let-text>
      <span>{{text}}</span>
    </template>
    <template #icon let-iconUrl let-width="width" let-height="height">
      <img [src]="iconUrl" [width]="width" [height]="height">
    </template>

    <!-- An example of providing a single value -->
    <template
        [ngTemplateOutlet]="text"
        [ngTemplateOutletValue]="textContext">
    </template>

    <!-- An example of providing a map of key/value pairs -->
    <template
        [ngTemplateOutlet]="icon">
        [ngTemplateOutletContext]="iconContext">
    </template>
  ''',
  directives: const [NgTemplateOutlet],
)
class ExampleComponent {
  final textContext = 'Hello world!';

  final iconContext = {
    '\$implicit': 'icon.png',
    'width': '16',
    'height': '16',
  };
}
Implemented types
Annotations

Constructors

NgTemplateOutlet(ViewContainerRef _viewContainerRef)

Properties

hashCode int
The hash code for this object. [...]
read-only, inherited
ngTemplateOutlet TemplateRef
The TemplateRef used to create the embedded view. [...]
@Input(), write-only
ngTemplateOutletContext Map<String, Object>
An optional map of local variables to define in the embedded view. [...]
@Input(), write-only
ngTemplateOutletValue Object
Provides a value to be assigned in scope to the provided template. [...]
@Input(), write-only
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited

Methods

ngDoCheck() → void
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
inherited
toString() String
A string representation of this object. [...]
inherited

Operators

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