Ionic window.connection not working if controller

Hello Guyz,

I have installed network info plugin and my code works fine .run function but when I am using the same code in controller it says
window.connection does not exists.

//Network Code
    if (window.Connection) {
        alert(" Connection Detected Yahooooo!!! :)");
    else {
      alert('Cannot find Window.Connection');

How can I access window.connection functionality in controller as well???

i struck in the initial stage where code in the app.js is doesnt working… could you explain me how should i correct my mistakes