Skip to content
This repository was archived by the owner on Sep 15, 2021. It is now read-only.

Commit d0028aa

Browse files
committed
fix(plugin:network): replace $apply() with $timout for online and offline events
1 parent 1cb428a commit d0028aa

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/plugins/network.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@
33

44
angular.module('ngCordova.plugins.network', [])
55

6-
.factory('$cordovaNetwork', ['$rootScope', function ($rootScope) {
6+
.factory('$cordovaNetwork', ['$rootScope', '$timeout', function ($rootScope, $timeout) {
77

88
var offlineEvent = function () {
99
var networkState = navigator.connection.type;
10-
$rootScope.$apply(function () {
10+
$timeout(function () {
1111
$rootScope.$broadcast('$cordovaNetwork:offline', networkState);
1212
});
1313
};
1414

1515
var onlineEvent = function () {
1616
var networkState = navigator.connection.type;
17-
$rootScope.$apply(function () {
17+
$timeout(function () {
1818
$rootScope.$broadcast('$cordovaNetwork:online', networkState);
1919
});
2020
};

0 commit comments

Comments
 (0)