The NFC-reader wrapper doesn’t work in secundary tab


#1

I’m using the code from nfc-reader wrapper https://github.com/konstantinkrassmann/ngCordova-nfc and works perfectly if it is implemented in the controller of the first tab of IONIC tab sample (http://ionicframework.com/getting-started/)

I have three tabs with three controllers(DashCtrl, ChatsCtrl and AccountCtrl). If the following code is used in the DashCtrl, the NFC-reader works fine, but when I pass code to the ChatsCtrl doesn’t work. Does anyone have an idea why it happens ?

the code is:

app.controller("ChatsCtrl", function($cordovaNfc, $cordovaNfcUtil){

  $cordovaNfc.then(function(nfcInstance){

        //Use the plugins interface as you go, in a more "angular" way
      nfcInstance.addNdefListener(function(event){
            //Callback when ndef got triggered
      })
      .then(
        //Success callback
        function(event){
            console.log("bound success");
        },
        //Fail callback
        function(err){
            console.log("error");
        });
   });

   $cordovaNfcUtil.then(function(nfcUtil){
        console.log( nfcUtil.bytesToString("some bytes") )
   });    
});