Block app without internet connection

Hello all,

I’m very new in Ionic and Javascript and I need a little bit help.
I use a Ionic SideMenu Template with different HTTP-Requests. I would like block the app or only the http-request and popup an alert.

I use this script enter link description here

When I connect or disable the internet-connection I see the network-state change the status.
But how can I implement this script??? When I inser an if($scope.isOnline) { }, the alertbox open, but in the background the http-request start