Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot call method 'paste' of undefined for ngCordova with ionic and phonegap build #14

Open
prantikv opened this issue Aug 21, 2015 · 2 comments

Comments

@prantikv
Copy link

i am using ionic ngCordova extention set and building my app using the phonegap build service.
phonegap version 3.7.0

i have added the plugin like so and it works great with the JavaScript way:

         window.plugins.clipboard.paste(function (text) { alert(text); });

but when i use the $cordovaClipboard i am getting this error:

      module.controller('ClipboardCtrl', function($scope, $cordovaClipboard) {
      $cordovaClipboard.paste().then(function (result) {
             // success, use result
            }, function () {
             // error
               });
         });

TypeError: Cannot call method 'paste' of undefined
at Object.paste (file:///android_asset/www/js/ng-cordova.min.js:7:15146)
at l.$scope.mypastefun(file:///android_asset/www/js/myCtrl.js:54:22)
at file:///android_asset/www/lib/ionic/js/ionic.bundle.min.js:229:303
at file:///android_asset/www/lib/ionic/js/ionic.bundle.min.js:388:5713
at l.$eval (file:///android_asset/www/lib/ionic/js/ionic.bundle.min.js:156:305)
at l.$apply (file:///android_asset/www/lib/ionic/js/ionic.bundle.min.js:157:6)
at HTMLButtonElement. (file:///android_asset/www/lib/ionic/js/ionic.bundle.min.js:388:5695)
at HTMLButtonElement.c (file:///android_asset/www/lib/ionic/js/ionic.bundle.min.js:63:389)
at n (file:///android_asset/www/lib/ionic/js/ionic.bundle.min.js:22:384)
at t (file:///android_asset/www/lib/ionic/js/ionic.bundle.min.js:22:216) ionic.bundle.min.js:133
(anonymous function) ionic.bundle.min.js:133
(anonymous function) ionic.bundle.min.js:107
l.$apply ionic.bundle.min.js:157
(anonymous function) ionic.bundle.min.js:388
c ionic.bundle.min.js:63
n ionic.bundle.min.js:22
t ionic.bundle.min.js:22
l ionic.bundle.min.js:22
t ionic.bundle.min.js:22
l ionic.bundle.min.js:22

This happens only on the build service and not in the CLI.

@floraluo
Copy link

@prantikv I have the same issue.Did you have a solution?

@maxlam79
Copy link

maxlam79 commented Mar 5, 2016

Have you included cordova.js (you won't find this in the project folder) in the index.html for ionic developments?

e.g. <script src="cordova.js"></script>

I had this problem initially, but after including this right after <script src="lib/ngCordova/dist/ng-cordova.min.js"></script>, it worked flawlessly.

** This plugin will not work on browser, but running it on android / ios works. e.g. ionic run android

Hope this helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants