0
我試圖在指令模板中過濾ng-repeat的結果。下面的解決方案,因爲它在屏幕上很好地顯示,但我現在得到的錯誤:Uncaught Error: [$rootScope:infdig] 10 $digest() iterations reached. Aborting!
我引用此頁和解決方案沒有工作:https://docs.angularjs.org/error/ $ rootScope/infdig通過JSON屬性過濾Angular模板獲取Digest無限循環
有關如何解決這個問題的任何建議?或者更好的方法去解決它?
HTML:
<filtered-set items="businesses | filter : {cat: 'jedi'} : true | filter:query |orderBy: orderList"></filtered-set>
模板:
<div class="bscroll mThumbnailScroller" data-mts-axis="x">
<ul>
<li class="business-card" data-ng-repeat="business in items" data-ng-click="select(business)">
<h2>{{business.name}}</h2>
<p>{{business.cat}}</p>
</li>
</ul>
</div>
角JS:
.controller('starWarsCtrl', function ($scope) {
$scope.businesses = [
{"name": "Obi-Wan Kenobi",
"index":88,
"cat": "jedi"},
{"name": "Yoda",
"index":69,
"cat":"jedi"},
{"name": "Lando",
"index":31,
"cat": "smuggler"},
{"name": "Han Solo",
"index":90,
"cat": "smuggler"},
{"name": "Darth Vader",
"index":98,
"cat": "sith"},
{"name": "Jar-Jar Binks",
"index":80,
"cat": "alien"},
{"name": "Mace Windu",
"index":45,
"cat": "jedi"},
{"name": "Chewy",
"index":76,
"cat": "smuggler"}
];
.directive('filteredSet', function() {
return {
restrict: 'E',
scope: {
items: '='
},
templateUrl: 'partials/filtered-set.html'
};
});
看看http://stackoverflow.com/questions/17198500/angular-js-pass-filter-to-directive-bi-directional-attribute/17199892#17199892和http://stackoverflow.com/questions/21675300/angularjs傳遞濾波陣列到指令 –