angular 5: templateRef.createEmbeddedView no es una función
Aquí está el código que estoy tratando de poner a trabajar (angular 5):
import { Component, ViewChild, TemplateRef, ViewContainerRef } from '@angular/core';
@Component({
selector: 'vcr',
template: `
<template #tpl>
<h1>ViewContainerRef</h1>
</template>
<div>Some element</div>
<div #container></div>
`,
})
export class VcrCmp {
@ViewChild('container', { read: ViewContainerRef }) _vcr;
@ViewChild('tpl') tpl: TemplateRef<any>;
constructor(
private viewContainerRef: ViewContainerRef
) {
}
ngAfterViewInit() {
console.info(this.viewContainerRef);
console.info(this._vcr);
this._vcr.createEmbeddedView(this.tpl);
this.viewContainerRef.createEmbeddedView(this.tpl);
}
}
El problema es que tengo esto (templateRef.createEmbeddedView is not a function
) error y realmente no entiendo por qué.
Este código se basa en este ejemplo.https://netbasal.com/angular-2-understanding-viewcontainerref-acc183f3b682 así que supongo que debería funcionar.
¿Qué estoy haciendo mal?