Angular 将元素编译到不带任何#localvariable的特定位置

Angular 将元素编译到不带任何#localvariable的特定位置,angular,dynamic,components,local-variables,Angular,Dynamic,Components,Local Variables,是否有任何方法可以将动态元素添加到特定位置而无需#localvariable() 例如,假设: <td></td> 汇编后: <td><input type='button' (click)='doSomething()'></td> 组件工厂。创建允许将选择器或节点作为目标参数传递: 构造函数(私有解析器:ComponentFactoryResolver,私有注入器:注入器){ ngAfterViewInit(){ 让工厂=t

是否有任何方法可以将动态元素添加到特定位置而无需
#localvariable

例如,假设:

<td></td>

汇编后:

<td><input type='button' (click)='doSomething()'></td>

组件工厂。创建
允许将选择器或节点作为目标参数传递:

构造函数(私有解析器:ComponentFactoryResolver,私有注入器:注入器){
ngAfterViewInit(){
让工厂=this.resolver.resolveComponentFactory(MyDynamicComponent);
让compRef=factory.create(注入器,[],“#idOfTarget”);
}

另请参见组件工厂。创建允许将选择器或节点作为目标参数传递:

构造函数(私有解析器:ComponentFactoryResolver,私有注入器:注入器){
ngAfterViewInit(){
让工厂=this.resolver.resolveComponentFactory(MyDynamicComponent);
让compRef=factory.create(注入器,[],“#idOfTarget”);
}

另请参见使用“ComponentFactory.create”如何将数据传递到组件中。我的第二个问题是是否可以将元素作为字符串而不是组件传递还显示了如何执行此操作。使用“ComponentFactory.create”我们如何将数据传递到组件中。我的第二个问题是是否可以将元素作为字符串而不是组件传递还显示了如何执行此操作。