是否可以从字符串中获取templateRef?

ape*_*hev 9 angular2-template ng-bootstrap angular

我感兴趣的是如何TemplateRef通过传递一个string例子来获得一个.

我不想通过组件html获取它,因为我只想将它保存在配置中以用于所有组件.我正在引用NgbDatePickerConfig可以在这里查看的ng-bootstrap :https://github.com/ng-bootstrap/ng-bootstrap/blob/master/src/datepicker/datepicker-config.ts.

ape*_*hev 3

正如 G\xc3\xbcnter Z\xc3\xb6chbauer 指出的那样,这是不可能的,而且可能不太有用,因为您经常想要捕获 的功能,因此template您将需要一个组件。

\n\n

然而,目前创建一个仅用于获取 a 的独立组件并不容易TemplateRef,因为您需要 aViewContainerRef才能做到这一点。\n当前 Angular 2 问题的目标是:https://github.com/angular/angular/issues/9293

\n