2017-12-09 22 views
0

저는 Angular와 이오닉 프레임 워크에 새롭고 cordova 이메일 작성기 플러그인을 통합하려고합니다. 그러나 이것을 완료하지 못했습니다. 여기 내 모든 코드가있다.CordovaEmailComposer 작업

나는 CLI 설치했다 :

ionic cordova plugin add https://github.com/katzer/cordova-plugin-email-composer.git 

에 Index.html을

<script src="lib/ionic/js/ionic.bundle.js"></script> 
    <script src="cordova.js"></script> 
    <script src="js/openfb.js"></script> 
    <script src="js/ngopenfb.js"></script> 
    <script src="js/ngCordovaOauth.js"></script> 
    <script src="settings.js"></script> 
    <script src="js/angular-translate.min.js"></script> 
    <script src="translate.js"></script> 
    <script src="js/app.js"></script> 
    <script src="js/services.js"></script> 
    <script src="js/controllers.js"></script> 
    <script src="js/directives.js"></script> 
    <script src="js/ngStorage.js"></script> 
    <script src="js/ionic-close-popup.js"></script> 
    <script src="js/angular-base64.js"></script> 

App.JS

angular.module('starter', ['ionic', 'starter.services', 'starter.controllers', 'starter.translate', 'ngStorage', 'ionic.closePopup', 'ab-base64', 'ngOpenFB', 'ngCordovaOauth','starter.directive']) 

컨트롤러 :

.controller('EmailController', function($scope) { 
    $scope.sendEmail=function(EmailAddr){ 
     var email = 
      { 
       to: '[email protected]', 
       subject: 'Test Message', 
       body: 'This is a test message', 
       isHtml: true 
      }; 
     $cordovaEmailComposer.isAvailable().then(function() { 
      $cordovaEmailComposer.open(email).then(null, function() { 
      // user cancelled email 
      }); 
     }, function() { 
      // not available 
     }); 
    };  
}) 
,

HTML : 오류 다음

SEND 버튼을 클릭
<div class="list theme-forms" ng-controller="EmailController"> 
<button class="button button-block button-positive" ng-click="sendEmail()">SEND</button> 
</div> 

은, 크롬 콘솔 및 이메일에 표시가 전송되지 않습니다 -

ionic.bundle.js:150 ReferenceError: $cordovaEmailComposer is not defined 
    at b.$scope.sendEmail (controllers.js:746) 
    at fn (eval at compile (ionic.bundle.js:260), <anonymous>:4:218) 
    at ionic.bundle.js:472 
    at b.$eval (ionic.bundle.js:176) 
    at b.$apply (ionic.bundle.js:177) 
    at HTMLButtonElement.<anonymous> (ionic.bundle.js:472) 
    at Pf (ionic.bundle.js:70) 
    at HTMLButtonElement.d (ionic.bundle.js:70) 
    at n (ionic.bundle.js:22) 
    at t (ionic.bundle.js:22) 

당신은 내가 여기에 놓친 어떤 힌트를 제공하는 데 도움이 수 있습니까?

EDIT 1

이제

내가 index.html을

js/ng-cordova.min.js 
js/email_composer.js // form Plugin files 

과 점점 오류 콘솔에서 JS 다음 파일을 추가 한 -

require is not defined 

SEND 버튼을 클릭 -

TypeError: Cannot read property 'isAvailable' of undefined 

답변

0
try to use this plugin:- 
http://ngcordova.com/docs/plugins/emailComposer/ 

module.controller('ThisCtrl', function($cordovaEmailComposer) { 

$cordovaEmailComposer.isAvailable().then(function() { 
    // is available 
}, function() { 
    // not available 
}); 

    var email = { 
    to: '[email protected]', 
    cc: '[email protected]', 
    bcc: ['[email protected]', '[email protected]'], 
    attachments: [ 
     'file://img/logo.png', 
     'res://icon.png', 
     'base64:icon.png//iVBORw0KGgoAAAANSUhEUg...', 
     'file://README.pdf' 
    ], 
    subject: 'Cordova Icons', 
    body: 'How are you? Nice greetings from Leipzig', 
    isHtml: true 
    }; 

$cordovaEmailComposer.open(email).then(null, function() { 
    // user cancelled email 
}); 
}); 
+0

코드 적용 후 콘솔에 오류가 발생했습니다. - –

+0

[$ injector : unpr] http://errors.angularjs.org/1.5.3/$injector/unpr?p0=ordovaEmailComposerProvider%20%3C-%20% 24cordovaEmailComposer % 20 % 3C- % 20EmailController –

+0

이제 index.html과 'js/ng-cordova.min.js'에 'js/email_composer.js'를 추가했습니다. 이제 콘솔에서 'require is not defined'가 표시됩니다. –