Stack trace:
Error: $apply already in progress
at Error (<anonymous>)
at beginPhase (file:///android_asset/www/built.min.js:7:22740)
at Object.Scope.$apply (file:///android_asset/www/built.min.js:7:25967)
at navigator.geolocation.getCurrentPosition.that (file:///android_asset/www/built.min.js:13:8670)
at Object.geolocation.getCurrentPosition (file:///android_asset/www/plugins/org.apache.cordova.core.geolocation/www/geolocation.js:122:13)
at Object.getCurrentPosition (file:///android_asset/www/built.min.js:13:8589)
at Object.getCurrentPosition (file:///android_asset/www/built.min.js:13:8277)
at Object.getCurrentCity (file:///android_asset/www/built.min.js:13:8941)
at Object.$scope.locateDevice (file:///android_asset/www/built.min.js:13:10480)
at file:///android_asset/www/built.min.js:7:12292:7
đề cập đến mã này http://pastebin.com/B9V6yvFu
getCurrentPosition: cordovaReady(function (onSuccess, onError, options) {
navigator.geolocation.getCurrentPosition(function() {
var that = this,
args = arguments;
if (onSuccess) {
$rootScope.$apply(function() {
onSuccess.apply(that, args);
});
}
}, function() {
var that = this,
args = arguments;
if (onError) {
$rootScope.$apply(function() {
onError.apply(that, args);
});
}
}, {
enableHighAccuracy: true,
timeout: 20000,
maximumAge: 18000000
});
})
Lạ một điều, trên tôi LG4X nó hoạt động tốt, tuy nhiên trên samsung của tôi s2 nó ném ở trên lỗi. Bất kỳ ý tưởng whats sai?
Bạn đã thử http://stackoverflow.com/a/12859093/1266600 chưa? Nó có thể là do các thiết bị khác nhau -> tốc độ xử lý khác nhau -> thời gian khác nhau, có thể gây xung đột ở một số nơi nhưng không gây ra xung đột khác. – sushain97
sử dụng '$ timeout()' –
+1 vào nhận xét $ timeout(). Xem: http://stackoverflow.com/questions/12729122/prevent-error-digest-already-in-progress-when-calling-scope-apply?answertab=active#21269546 – Trevor