我的主要问题是错误没有指向我的代码中的任何位置,我们没有那么多的$apply
调用我们的项目。该似乎的代码中生成错误:
<input type="text"
placeholder="{{ $root.pg.t('HEADER.CITY_OR_POSTAL') }}"
data-ng-focus="decideToStop();" data-ng-blur="decideToStart()"
data-ng-model="search.selected"
typeahead-on-select="search.locationQuery(geo_locations, search.selected)"
typeahead="location.name for location in getLocations($viewValue) | filter: $viewValue | limitTo:8" class="semi-bold">
在控制器:
$scope.decideToStop = function(){
if($scope.actionTimeout){
$timeout.cancel($scope.actionTimeout);
$scope.actionTimeout = {};
}
$scope.MyService.CustomMethodThatDoesALotOfThings();
};
$scope.decideToStart = function(){
if(CustomCondition()){
$scope.actionTimeout = $timeout(function(){
$scope.MyService.AnotherCustomMethodThatDoesALotOfThings();
}, 150);
}
};
$root.pg
仅仅是被放置在rootScope
现在服务内的polyglot.js库。 search
是与位置搜索对应的服务。
我在输入字段中更改城市时出现错误。我不知道如何调试这...
ngFocus和ngBlur在一起玩的不好。当你删除其中一个时会发生什么? – Narretz
我删除了ng-focus并解决了问题。但是...我需要两个! –