0
有没有办法在组件模板中动态创建html标签?Angular 2动态创建html标签
像这样的事情
template:`<{{custom_tag}} [info]="info"></{{custom_tag}}>`
...
this.custom_tag="example";
this.info={};
生成的HTML将是这样的
<example info="..."></example>
有没有办法在组件模板中动态创建html标签?Angular 2动态创建html标签
像这样的事情
template:`<{{custom_tag}} [info]="info"></{{custom_tag}}>`
...
this.custom_tag="example";
this.info={};
生成的HTML将是这样的
<example info="..."></example>
我有同样的问题,我有一个指令解析更换标签:
通过定制html标签,你实际上是指一个组件?这是关于动态组件的问题吗? –
@PeterMatisko是的。该标签将是一个组件 –
我正在解决类似的问题。请检查我的问题和答案,这可能会有所帮助:http://stackoverflow.com/questions/42215288/angular2-dynamic-components-in-content-received-by-api 您需要使用编译器来动态添加组件。 –