I am trying to send an e-mail when I click on a button. I have followed a tutorial but what I have done does not work.
This is my code:
app.js:
angular.module('starter', ['ionic'])
.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('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
}else{
$scope.a='There is an error in your app' //siempre me imprime este else
}
}
});
index.html:
<ion-content ng-controller="EmailController">
<button class="button" ng-click="sendFeedback()">send</button>
<br>
{{a}}
</ion-content>
Also, I would like to add the following:
-
The version of my ionic is 1.7.14
-
In the tutorial where I saw the plugin, it refers to this git repository: first repository and the plugin that I installed with
ionic plugin add cordova-plugin-email-composer
refers to this one: second repository
Why does not my code work? and why are the plugins different?
If the error is the plugins, how can I fix my code?