我正在尝试这样做:
ng-repeat="note in notes|filter:basicFilter"
)有没有办法检查过滤器在“基本”过滤器之后产生什么,所以我可以执行$ http回调服务器?是否有一个内置于角度的“过滤器”,我可以调用它?
我试过看变量:
$scope.$watch('filtered_notes', function() {
// can't do this
});
ng-repeat="note in filtered_notes = (notes | orderBy:['-note_time']|filter:noteFilter|limitTo:limit)"
但是,它会引发错误:Uncaught Error: [$rootScope:infdig] 10 $digest() iterations reached. Aborting!
答案 0 :(得分:1)
您可以创建自定义过滤器,例如以下示例
<强> HTML 强>
<div ng-repeat="note in filtered_notes | myCustomFilter:theInput">
自定义过滤器JS
iApp.filter('myCustomFilter', function() {
return function( notes, input) {
var filtered = [];
angular.forEach(notes, function(item) {
if(/* do any condition with 'input' */) {
filtered.push(item);
}
});
if(filtered.length >= 5 ){
/* do HTTP call or use $broadcast to trigger HTTP call*/
}
return filtered;
};