2016-06-14 21 views
1

我想通過使用科爾多瓦/離子發送電子郵件,但我得到上述錯誤。我已遵循所有的步驟,我想跟着,我走了通過與此相關的其他文章但仍找不到解決方案。無法讀取屬性的'插件'未定義Object.isAvailable

的index.html是

<!DOCTYPE html> 
<html> 
    <head> 
    <meta charset="utf-8"> 
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width"> 
     <meta http-equiv="Content-Security-Policy" content="default-src 'self'; frame-src 'self' https://cordova.apache.org"> 

     <title></title> 

    <link href="lib/ionic/css/ionic.css" rel="stylesheet"> 
    <link href="css/style.css" rel="stylesheet"> 

    <!-- IF using Sass (run gulp sass first), then uncomment below and remove the CSS includes above 
    <link href="css/ionic.app.css" rel="stylesheet"> 
    --> 

    <!-- ionic/angularjs js --> 
    <script src="lib/ionic/js/ionic.bundle.js"></script> 

    <!-- cordova script (this will be a 404 during development) --> 
<script src="lib/ng-cordova-master/dist/ng-cordova.js"></script> 

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

    <!-- your app's js --> 
    <script src="js/app.js"></script> 
    <!--<script src="js/EmailComposer.js"></script>--> 
    </head> 
    <body ng-app="starter"> 

    <ion-pane> 
     <ion-header-bar class="bar-stable"> 
     <h1 class="title">Ionic Blank Starter</h1> 
     </ion-header-bar> 
     <!--<ion-content ng-controller="EmailController">--> 
     <ion-content ng-controller="EmailCtrl"> 
      <!--<button class="button" ng-click="sendFeedback">--> 
       <!--Send messege--> 
      <!--</button>--> 
      <button ng-click="sendEmail()" class="button button-icon icon ion-email"style="padding-top: 100px"> 
       Send mail 
      </button> 

     </ion-content> 
    </ion-pane> 
    </body> 
</html> 

app.js是

// Ionic Starter App 

// angular.module is a global place for creating, registering and retrieving Angular modules 
// 'starter' is the name of this angular module example (also set in a <body> attribute in index.html) 
// the 2nd parameter is an array of 'requires' 
//var exampleApp = angular.module('starter', ['ionic','ngCordova']) 
var app =angular.module('starter', ['ionic','ngCordova']) 

.run(function($ionicPlatform) { 
    $ionicPlatform.ready(function() { 
    if(window.cordova && window.cordova.plugins.Keyboard) { 
     // Hide the accessory bar by default (remove this to show the accessory bar above the keyboard 
     // for form inputs) 
     cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true); 

     // Don't remove this line unless you know what you are doing. It stops the viewport 
     // from snapping when text inputs are focused. Ionic handles this internally for 
     // a much nicer keyboard experience. 
     cordova.plugins.Keyboard.disableScroll(true); 
    } 
    if(window.StatusBar) { 
     StatusBar.styleDefault(); 
    } 
    }); 
}) 

    .controller('EmailCtrl',[ "$cordovaEmailComposer", function($cordovaEmailComposer, $scope) { 
     $cordovaEmailComposer.isAvailable().then(function() { 
      // is available 
      alert("available"); 
     }, function() { 
      // not available 
      alert("not available"); 
     }); 
     $scope.sendEmail = function(){ 
      var email = { 
       to: '[email protected]', 
       cc: '[email protected]', 
       bcc: ['adishri.taarago.com', 'adishri.taarago.com'], 
       //attachments: [ 
       // 'file://img/logo.png', 
       // 'res://icon.png', 
       // 'base64:icon.png//iVBORw0KGgoAAAANSUhEUg...', 
       // 'file://README.pdf' 
       //], 
       subject: 'Mail subject', 
       body: 'How are you? Nice greetings from Leipzig', 
       isHtml: true 
      }; 

      $cordovaEmailComposer.open(email).then(null, function() { 
       // user cancelled email 
      }); 
     } 
    }]); 
//exampleApp.controller('EmailController', function($scope) { 
// $scope.sendFeedback= function() { 
// if(window.plugins && window.plugins.emailComposer) { 
//  window.plugins.emailComposer.showEmailComposerWithCallback(function(result) { 
//   console.log("Response -> " + result); 
//   }, 
//   "Feedback for your App", // Subject 
//   "",      // Body 
//   ["[email protected]"], // To 
//   null,     // CC 
//   null,     // BCC 
//   false,     // isHTML 
//   null,     // Attachments 
//   null);     // Attachment Data 
// } 
// } 
//}); 

誰能幫我解決這個問題? 在此先感謝。

回答

1

請嘗試在真實設備或甚至模擬器上進行測試。控制器似乎很難找到'插件',我在嘗試實現cordovaClipboard時遇到了同樣的錯誤,當我使用離子服務器運行時遇到了錯誤,但如果我在手機上運行它,一切都很好。

相關問題