0
嘗試使用android在phonegap中創建android應用程序。
angular.module('myModule').config(['$rootScope', function($rootScope) {
$rootScope.internet = { status: 0, type: 'none'};
document.addEventListener("offline", function(){
$rootScope.internet.status = 0;
$rootScope.internet.type = navigator.connection.type;
}, false);
document.addEventListener("online", function(){
$rootScope.internet.status = 1;
$rootScope.internet.type = navigator.connection.type;
}, false);
}]);
我只想在navigator.connection更改或進行聯機/脫機時更改全局可變參數。
或者我該如何將watch
綁定到此navigator.connection
全局變量。
@ubombi它能幫你嗎? –