ng-repeat是否在ng-bind-html中有效?
其中res2是StaticPage内容。 res是一个json文件。请注意,我可以从作用域中获取变量(也可以打印json数组),但不能使用ng-repeat进行迭代。
家庭控制器:
$rootScope.usefulContent = res;
$rootScope.staticContent = $interpolate(res2)($rootScope);
查看:
<div ng-controller="homeCtrl" class="headerSize" id="staticPage">
<div ng-bind-html="staticContent"></div>
</div>
静态页面:
<div class="container content-home">
<div class="row">
<div class="col-sm-6">
<div class="row">
<div class="col-xs-12">
<div ng-repeat="(key, value) in usefulContent | groupBy: 'Order'">
{{key}}
</div>
<ul class="list-group" data-ng-repeat="(key, value) in usefulContent | groupBy: 'Order'">
<li class="list-group-item">{{key}}
<ul class="list-group">
<li class="list-group-item child" data-ng-repeat="link in value">
{{ link.SUBSECTION }}
</li>
</ul>
</li>
</ul>
</div>
</div>
</div>
<div class="col-sm-6">
Col 2
</div>
</div>
</div>
JSON:
[
{
"Order": 1,
"SECTION": "HR",
"SUBSECTION": "Administration",
},
{
"Order": 1,
"SECTION": "HR",
"SUBSECTION": "Self Service",
}
]
谢谢。