【问题标题】:ng-repeat inside ng-bind-htmlng-repeat 在 ng-bind-html 中
【发布时间】:2017-08-13 08:31:30
【问题描述】:

如果我有一个div如下

<div ng-bind-html="myHtml"></div>

而myHtml定义如下

$scope.names = ['A','B','C'];
$scope.myHtml = "<p ng-repeat=\"name in names\" ng-bind=\"name\"></p>";

为什么在这种情况下 ng-repeat 不处理?

【问题讨论】:

    标签: angularjs angularjs-ng-repeat ng-bind-html


    【解决方案1】:

    您可以使用bind-html-compile 指令代替bind-html

    ngBindHtml 我们用于 HTML,没有像 ng-repeatng-model 这样的角度指令,而是单个 DOM


    Angular 应该知道新的变化并输入它们以消化循环。出于这个原因,我们需要将ngBindHtml$compile 合并。这是bind-html-compile 指令的目的,应该同时做这两件事。

    【讨论】:

      猜你喜欢
      • 2016-05-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-02-09
      • 1970-01-01
      • 2015-05-06
      • 2013-11-21
      • 2014-03-31
      相关资源
      最近更新 更多