$location.path not routing inside $ionicPlatform.ready


#1

I’m trying to check if a device has an internet connection using the cordova plugin org.apache.cordova.network-information, but this will be available when the device was ready.

So I made a controller to check the connection and checks the device if ready with

$ionicPlatform.ready( function( ) {
if ( navigator.connection.type == Connection.UNKNOWN || navigator.connection.type == Connection.NONE ) {
// Fires no connection status POPUP
} else {
// Route to collects data
$location.path( ‘/path’ );
}
});

When on desktop browser, and replace the navigator with navigator.onLine, there is no problem, also there is no problem when there is no network connection it runs the popup.

The problem is when there is a connection. It does not runs the $location.path or a function of a service.

Is there something I missed?