Closed
Description
There are cases where we've got a reference to a TemplateRef
and would like to use it to stamp out live HTML fragments. Currently it can be easily done from the JS side (viewContainerRef.createEmbeddedView(tplRef)
) but this issue is about creating a directive that would allow us to do this "inserting" from a template.
A "workish" example of such directive:
@Directive({
selector: 'ng-insert-tpl'
})
export class NgInsertTpl {
constructor(private _viewContainerRef: ViewContainerRef) {
}
@Input() set template(tplRef: TemplateRef) {
this._viewContainerRef.createEmbeddedView(tplRef);
}
}
Naming things is hard so ng-insert-tpl
is definitively up to debate.
This is part of #7546 (comment), it could be used in action like so: http://plnkr.co/edit/sleVVrgqo66JN9G48yyj?p=preview