can not use another component in innerHTML property binding

心不动则不痛 提交于 2019-12-11 14:27:59

问题


I have created a sample with innerHTML binding property. I want to use other component inside my template like below:

export class AppComponent  {
        constructor(private sanitized: DomSanitizer) {}

   name = 'Angular';
  public bar = 'bars';
  foo = this.sanitized.bypassSecurityTrustHtml( `<div>`+this.bar+`
  </div>
  <hello></hello>
`);
}

hello-component

import { Component, Input } from '@angular/core';

@Component({
  selector: 'hello',
  template: `<button ejs-button>Button</button>`
})
export class HelloComponent  {
  @Input() name: string;
}

Sample - https://stackblitz.com/edit/angular-vdf66x?file=src/app/app.component.ts

来源:https://stackoverflow.com/questions/56289132/can-not-use-another-component-in-innerhtml-property-binding

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!