Cannot read property 'plugins' of undefined?

I installed ngCordova and included the js properly, I added the dependency too to my module, then I add clipboard plugin, then I do this code in my mainCtrl

    .copy('text to copy')
    .then(function () {
      // success
    }, function () {
      // error

I gotten the error of Cannot read property ‘plugins’ of undefined, I guess I’ve done everything correctly? What might me the cause, any idea guys? No clue here what’s going on…

Do you see the plugin installed in plugins/ folder?
Did you install ng-cordova correctly, Including ‘NgCordova’ DI in module declaration, and in index.html by adding the ng-cordova.js script after ionic, but before cordova.js?

YES, I did everything u mentioned.

Well, that makes the two of us, I think.
Im still investigating it my own, but I tried playing a bit with ngCordova myself, and while in the…) I can see window.cordova.plugins and inside all my installed plugins, in my controller its not able to get the object, and window.cordova.plugins.* contains only the keyboard.
I’ll update if I see something regarding it, hopefuly you will too.

not sure how those people are struggling with problems

I answered the same question on SO – I think you may be trying to use the cordova plugin in the browser. You’ll need to emulate to Android or iOS to make use of it.

1 Like