且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Angular 2 将动态模板解析为字符串

更新时间:2021-12-13 04:30:40

如果你在innerHtml属性中注入你的模板并使用DomSanitizer,它会像一个组件一样翻译它,给你延迟加载的效果.

If you inject your template in the innerHtml attribute and use the DomSanitizer, it will translate it just like a component, giving you the lazy load effect.

<div [innerHTML]="myComponentsTemplate"></div>