如何从 angularjs 表达式打印 html?

How to print html from angularjs expression?

假设我要打印以下内容 html:

<a href..?> </a>

我把它放在一些表达式中。

我怎样才能打印它以便在 angular js ng-repeat 中使用 {{x.something}} 可以点击它?

你可以做 2 件事中的 1 件事。

  1. 使用具有 ng-bind-html 属性的 $sce 服务。 $sce 要求您在绑定到 UI.
  2. 之前围绕 html 内容调用 $sce.trustAsHtml()
  3. 使用ngSanitize(通过将其添加为依赖模块)然后使用ng-bind-html