如何离线和在线检查角度 [英] How can check offline and online in angular

查看:144
本文介绍了如何离线和在线检查角度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当浏览处于离线模式时,我从服务调用中收到错误。当浏览器处于离线模式时,如何检查离线模式并希望阻止我的服务呼叫?

I have been getting an error from the service call when browse is in offline mode. How can check off-line mode and want to block my service call when the browser is the offline mode?

推荐答案

我建议你使用 Offline.js

他们有模板和其他东西可以使用。
您可以查看他们的文档,看看它是如何工作的。

they have templates and other stuff to work with . you can check out their documentation and see how it works .

它通过返回向上或向下结果来获取连接的当前状态,或者您可以绑定和事件到它并在您的应用程序中使用它。

it gets you the current state of the connection by returning the "up" or "down" result , or you can bind and event to it and use it across you'r application .

这是他们对图书馆的看法:

this is what they say about their library :


Offline.js是一个库当用户丢失互联网连接时会自动提醒用户,例如Gmail。

Offline.js is a library to automatically alert your users when they've lost internet connectivity, like Gmail.

它会捕获连接断开时发出的AJAX请求,并在备份时重新制作,所以你的应用程序反应完美。

It captures AJAX requests which were made while the connection was down, and remakes them when it's back up, so your app reacts perfectly.

它有许多漂亮的主题,不需要配置。

It has a number of beautiful themes and requires no configuration.

祝你好运,玩得开心。

这篇关于如何离线和在线检查角度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆