且构网

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

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

更新时间:2021-09-20 04:27:08

如果将模板插入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>