display connection error messages in ionic framework

Solutions Collect From Internet About “display connection error messages in ionic framework”

–first add the plugin to your project
then in your app.js include the below code


document.addEventListener("offline", onOffline, false);

        $rootScope.online = true;
        function onOffline() {
            // Handle the offline event
            $rootScope.$apply(function() {
                $rootScope.online = false;
               alert("There is no active internet connection to your app. Please check the connectivity.");
               //implement your method off error when the connection terminates


        document.addEventListener("online", function() {
            $rootScope.$apply(function() {
                $rootScope.online = true;
        }, false);

here offile will handle the connection termination and online will handle the reconnection and check with the alerts or consoles