title: Ionic 2 : Access to a variable value from a provider or page
body: <p>I have a problem in Ionic 2 and maybe one of you could help me out.
  Basically, I have a provider that i'm building which includes the function BLE. I include this provider in one my page. And from this page I can call the function without problem. But what I want, is to access the public variable that is the provider. This variable is a status connection (true or false) and I want to access it from my page to know if I'm connected with BLE or not.</p>
  
  <p>here's my code</p>
  
  <p>BleProvider.ts</p>
  
  <pre><code>@Injectable()
  export class BleProvider {
  
  public isConnected:boolean;
  
  constructor(public http: Http) {
   console.log('Hello BleProvider Provider');
  }
  
  connectToDevice(device){
   this.isConnected = true;
  }
  }
  </code></pre>
  
  <p>My page Login.ts</p>
  
  <pre><code>import { BleProvider } from '../../providers/ble/ble'
  @IonicPage()
  @Component({
  selector: 'page-login',
  templateUrl: 'login.html',
  })
  @NgModule({
  providers: [BleProvider],
  })
  
  export class LoginPage {
  
  constructor(public ble: BleProvider){
   ble.connectToDevice();
  }
  
  function testIsConnected(){
  console.log("isConnected value: " + this.ble.isConnected);
  }
  }
  </code></pre>
  
  <p>The console.log will return "isConnected value: undefined. And if i set isConnected in the constructor of the provider (e.g. this.isConnected = false) even that the function connectToDevice will set isConnected at true, when i call it from my page it will return the value false.
  Can someone explain to me what happens and how to solve this?</p>