Angular 2 binding/events not working when adding template as innerHTML

前端 未结 1 1359
醉话见心
醉话见心 2020-12-02 02:01

I am trying to create a reusable table which can be configurable. The cells can be configured to have html template.

I am configuring the column \"Review

相关标签:
1条回答
  • 2020-12-02 02:39

    Angular doesn't process HTML added using innerHtml (also ElementRef.nativeElement.append(...) or similar) in any way.

    As mentioned in the comment an alternative is to wrap the HTML in a component and add this component dynamically. DynamicComponentLoader (as shown in the linked answer from the comment to your question) is deprecated. It was replaced by ViewContainerRef.createComponent(). Angular 2 dynamic tabs with user-click chosen components shows an example how to use it.

    0 讨论(0)
提交回复
热议问题