Adding Event Listener to page (not the whole app)


#1

Right now I add a couple of event listeners to check when the phone goes online/offline.

document.addEventListener('online', onOnline, false);
document.addEventListener('offline', onOffline, false);

This works fine, but since I’m attaching the listener to the document, it applies to every page in my app.

How would I do this for only one page? (Or several maybe, but not the whole app).


#2

You could use the network information events from ionic-native

http://ionicframework.com/docs/v2/native/Network/


#3

how to use this now. your link not working


#4