我需要sublist
在页面的几个地方使用指令,它有时应该包含完整fields
列表,但有时会被过滤。这是我天真的方法:
HTML:
<div ng-controller="MainCtrl">
<sublist fields="fields" /> <!-- This one is OK -->
<sublist fields="fields | filter: 'Rumba'" /> <!-- This one raises error -->
</div>
Javascript:
angular.module('myApp', [])
.directive('sublist', function () {
return {
restrict: 'E',
scope: { fields: '=' },
template: '<div ng-repeat="f in fields">{{f}}</div>'
};
})
.controller('MainCtrl', function($scope) {
$scope.fields = ['Samba', 'Rumba', 'Cha cha cha'];
});
当我尝试使用过滤器时,出现此错误:
Error: 10 $digest() iterations reached. Aborting!
这个问题有解决方案吗?