How to use string retrieved from back-end as template in Angular2?

前端 未结 2 1631
生来不讨喜
生来不讨喜 2021-01-29 10:24

In an Angular2 app, I\'d like to use ajax to retrieve a html tag string from back-end and use it as template in Angular2.

// The str I get from server by ajax i         


        
2条回答
  •  执笔经年
    2021-01-29 10:43

    Instead of a template, pass the string to $compile to create a DOM element: https://docs.angularjs.org/api/ng/service/$compile

提交回复
热议问题