I have been working on an Angular/Cordova app and I am trying to pass the online/offline status to Angular:
export class AppComponent implements OnInit {
isOff = false;
constructor() {
document.addEventListener('deviceready', onDeviceReady, false);
function onDeviceReady() {
document.addEventListener('offline', onOffline, false);
document.addEventListener('online', onOnline, false);
function onOffline() {
alert('You are offline.');//It's working
this.isOff = true;//Not functioning
}
function onOnline() {
alert('You are Online.'); //It's working
this.isOff = false; //Not functioning
}
}
}
}