Unknow provider on cardIO plugin using ngCordova Ionic

557 Views Asked by At


I'm trying to use cardIO plugin with ngCordova, but I'm getting this error:

Error: [$injector:unpr] Unknown provider: $cordovaNgCardIOProvider <- $cordovaNgCardIO <- SoldeCtrl

Usually this means that a dependency is not injected but I don't think it's the case here:

var app = angular.module('mDinar', ['ionic', 'ngCordova']);
app.controller('SoldeCtrl', function($scope, $cordovaNgCardIO, $cordovaToast) {
    $scope.currentSolde = 50;
    $scope.ajoutCompte = function() {
        $cordovaNgCardIO.scanCard();
    }
});

...
<div class="card">
  <div class="item item-text-wrap">
    <button id="scanBtn" class="button button-balanced icon-left ion-plus-circled" ng-click="ajoutCompte()">Ajouter un compte</button>
  </div>
</div>
...

ngCordova lib (github):

/* globals CardIO: true */
angular.module('ngCordova.plugins.cardIO', [])

  .provider(
  '$cordovaNgCardIO', [function () {
/* */
  }]
);

I don't know what I'm missing, please help.

1

There are 1 best solutions below

1
On BEST ANSWER

You could add 'ngCordova.plugins.cardIO' as explicit dependency to 'mDinar', as I stated in the comments above.

You also needed to wait till the deviceReady event was fired as you noted in your comment, to make sure the plugins are loaded when tried to use $cordovaNgCardIO in your controller.