0
ng-repeat在ng-bind-html內部工作嗎?ng-repeat-ng和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",
}
]
謝謝。
哪個ng-repeat不起作用? – sudo
另外,你可以發佈你試圖迭代的JSON嗎? – sudo
完成,並且兩個ng-repeat都不起作用 – blas