我的问题是我想延迟 AngularJS 中的 ng-repeat 结果。我的延迟过滤器代码如下。
<ul>
<li ng-repeat="phone in phones | filter:delay_filter">
<span>{{phone.name}}</span>
</li>
</ul>
<script>
var phonecatApp = angular.module('phonecatApp', ['ngMessages']);
phonecatApp.controller('PhoneListCtrl', function ($scope, $http, $scope) {
$scope.delay_filter=function(item){
alert(++$c);
x=setTimeout($scope.trf(),2200);
return item;
};};)
</script>
但这行不通。搜索会立即给出结果。 我没有在 html 中编写 Controller ,我知道这一点。在我的代码中它就在那里。那不是问题。请帮我解决这个问题
最佳答案
我认为你应该使用 angular.filter 创建一个指令或一个单独的过滤器。 否则,如果你想让它工作,你可以使用 $timeout
关于javascript - 使用过滤器延迟 ng-repeat 结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31517180/