【发布时间】:2018-07-20 20:32:16
【问题描述】:
我正在使用 ionic 进行开发,但在检查是否有互联网连接时遇到问题。
这是我检查互联网连接的代码:
$scope.checkConnection = function() {
if(navigator && navigator.connection && navigator.connection.type === 'none') {alert('no conexion');}
else{alert('conectado');}
};
我在 index.html 中这样称呼它:
<body ng-app="myApp" ng-controller="checkNetworkController" ng-init="checkConnection()">
当我启动应用程序时,我得到: 应用程序错误 - 与服务器的连接不成功。 (file:///android_asset/www/index.html)
如果我不调用 checkConnection 一切正常。 我尝试重新安装cordova网络插件,并在config.xml中添加:
<preference name="loadUrlTimeoutValue" value="700000" />
但是没有任何效果。有什么想法吗?
【问题讨论】:
标签: networking ionic-framework server connection