Detect internet working or not in Cordova Ionic Framework

I want show message when internet not working in cordova Ionic Application, Can anybody done this in Ionic Cordova Application.

There is a network-information plugin to get network information from the device. Add the

cordova plugin add org.apache.cordova.network-information

include it and in app.js and register an offline event handler from within the onDeviceReadyevent handler,

onDeviceReady: function() {
    document.addEventListener("offline", onOffline, false);
},

onOffline: function () {
  //handle offline 
}

here is some discussion on the ionic forum: http://forum.ionicframework.com/t/how-to-check-network-coneection/15806/14

you can find a lot like this one. I would suggest to use ngCordova and do something like this:

$rootScope.$on('$cordovaNetwork:online', function() {});
$rootScope.$on('$cordovaNetwork:offline', function() {});

Hi there is another issue here. Network information only tells you wether there is a connection. But that doesn't mean you have connection to a website and/or a running database. In most cases an app depends on the website and/or the database are available. So you have to check those too.