Angular2 innerHtml binding breaks data binding

前端 未结 1 866
太阳男子
太阳男子 2020-12-21 15:47

I am trying to bind to innerHtml while keeping data binding. This does not work (outputs {{myVar}}).

@Component({
  selector: \"test\",
  template: `
    <         


        
相关标签:
1条回答
  • 2020-12-21 16:19

    Angular2 doesn't process HTML added dynamically, therefore {{}}, [], (), ... isn't supposed to work. Also no components or directives are created, even when HTML added this way matches their selectors.

    Only markup added statically to components template are processed.

    Equivalent of $compile in Angular 2 demonstrates an approach if you really need it.

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