$消化已在进行中 [英] $digest already in progress
本文介绍了$消化已在进行中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我获取使用$ http.get数据(),并把它当作参数传递给自定义过滤器,以获得filterd数据。但它给人一种
错误: $消化正在进行中
有谁知道如何避免这个错误或达到同样的事情,但以不同的方式?
\r
\r\r
\r VAR地图= angular.module(地图,[])\r
.controller('mapCtrl',函数($范围,$过滤器,$ HTTP){\r
$ http.get('./ JSON / integrated.json')。成功(功能(数据){\r
$ scope.sitesInfo =数据;\r
});\r
变种filteritems = $滤波器('applySfotwareFilter')($ scope.sitesInfo);\r
\r
});
\r
解决方案
我觉得你应该把
VAR filteritems = $过滤器('applySfotwareFilter')($ scope.sitesInfo);
您的成功函数中;
什么情况是在你的数据准备好滤波开始。
I'm fetching the data using $http.get() and passing it as argument to a custom filter to get the filterd data. But it is giving an error: $digest already in progress.
Does anyone know how to avoid this error or achieve the same thing but a different way?
var map=angular.module('map', [])
.controller('mapCtrl', function ($scope,$filter,$http) {
$http.get('./json/integrated.json').success(function(data) {
$scope.sitesInfo = data;
});
var filteritems= $filter('applySfotwareFilter')($scope.sitesInfo);
});
解决方案
I think you should place
var filteritems= $filter('applySfotwareFilter')($scope.sitesInfo);
inside your success function;
What happens is the filtering starts before your data is ready.
这篇关于$消化已在进行中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文