[英]injecting dynamic html inside the components from index.html in angular 8
我正在开发 web 应用程序。 其中有玉兰作为CMS。 我还是新来的,但我会解释这个场景。 magnolia 提供了索引。html 有组件的参考。但是对于其中一些组件,它还提供了一些额外的 html 内容。 此附加内容必须显示在特定组件的模板中。 请参阅以下内容以获得更好的理解。(记住这是在 index.html 中)
<my-component>
<div> this division has to be shown inside the my component template.</div>
</my-component>
到目前为止,我已经尝试过以下方法。
如果这个问题有更好的或其他的解决方案,有人可以建议我吗?
您是否尝试过为该组件使用 Input() 值?
<my-comp [myInputs]="'My Input HTML <b>Content</b>'">
<div [innerHTML]="myInputs"></div>
在我这边,我在要放置动态内容的组件内使用<ng-content></ng-content>
。
前任:
<app-help-tool>
<span i18n="@@pictoTable_helpPictoList">Click on a picto to see its description.</span>
</app-help-tool>
在 HelpToolComponent.ts 中:
<div
class="help_content"
*ngIf="this.isVisible && this.helpService.isHelpOn()"
[@showHideHelp]
(click)="showHideHelp()"
>
<ng-content></ng-content>
</div>
结果就是把span的内容放到了组件的div中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.