I am implementing the structural directive in Angular2.
In the docs, I saw that I need to inject the TemplateRef
to get the template element and the ViewContainerRef
.
class TestDirective {
constructor( private templateRef : TemplateRef<any>, private viewContainer : ViewContainerRef ) {
// this.viewContainer.createEmbeddedView(this.templateRef);
}
}
<template [ngIf]="condition">
<p>
Our heroes are true!
</p>
</template>
In this case what I don't understand which element is the ViewContainerRef
?