我有一个有很多控制器的应用程序,其中大多数都向服务器发送请求。我想做的是检查是否有互联网连接。
我这样做使用:
if(navigator.network.connection.type == Connection.NONE){
alert("Oops! You are not connected to the internet!");
}else{
alert("Yes! You are connected to the internet!");
};
app.js 在哪里,我应该如何检查每个请求是否有互联网连接?我试图.config在 my 之前添加,authInterceptor但我无法使其工作。
附言。只有当我将它放在控制器内的函数中并调用它时,它才有效。