我試過發送電子郵件通過參考各種鏈接,但徒勞。我只是想發送電子郵件,以下是我的代碼發送電子郵件。請建議更改。
感謝提前:)
的index.html如何使用角度js和離子框架發送電子郵件
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
<title></title>
<link href="lib/ionic/css/ionic.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">
<script src="lib/ionic/js/ionic.bundle.js"></script>
<script src="lib/ionic/js/ng-cordova.min.js"></script>
<script src="js/cordova.js"></script>
<script src="js/app.js"></script>
</head>
<body ng-app="starter" ng-controller="ExampleController">
<ion-pane>
<ion-content>
<div class="padding">
<button class="button button-icon icon ion-email" ng-click="vesitEmail()">
Send Email
</button>
</div>
</ion-content>
</ion-pane>
</body>
</html>
App.js
var example=angular.module('starter', ['ionic','ngCordova'])
.run(function($ionicPlatform) {
$ionicPlatform.ready(function() {
if(window.cordova && window.cordova.plugins.Keyboard) {
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
cordova.plugins.Keyboard.disableScroll(true);
}
if(window.StatusBar) {
StatusBar.styleDefault();
}
});
});
example.controller('ExampleController', function($scope,$cordovaEmailComposer) {
$cordovaEmailComposer.isAvailable().then(function() {
// is available
alert("available");
}, function() {
// not available
alert("not available");
});
$scope.vesitEmail = function(){
var email = {
to: '[email protected]',
cc: '[email protected]',
bcc: null,
attachments: null,
subject: 'Mail subject',
body: 'How are you? Nice greetings from Leipzig',
isHtml: true
};
$cordovaEmailComposer.open(email).then(null, function() {
// user cancelled email
});
}
window.alert("Message Sent");
});
,當我在瀏覽器中測試它顯示如下錯誤:
TypeError: Cannot read property 'plugins' of undefined
當我在手機上測試它,它也不起作用。
你能確認window.cordova和window.cordova.plugins可用嗎? – Matheno
我該怎麼做? –
以防萬一..!檢查'org.apache.cordova.statusbar'插件是否安裝..!因爲您使用'window.StatusBar'..!插件問題解決先生 –