I want to use Cordova Email Plugin in an ionic application.
I can access the plugin in the $ ionicPlatform function, but when I moved my code to my controller in the function for the ng-click descriptor, this does not work.
Know that my question is: how to access the cordova plugin objects from the controller?
This is my code that I use in app.js and it worked:
.run(function($ionicPlatform) { $ionicPlatform.ready(function() { cordova.plugins.email.isAvailable( function (isAvailable) { alert('Service is available'); } );
This is the same code in the .js controller that did not work (I installed my controller in my route):
.controller('ApplicationController', function($scope) { $scope.sendMail = function () { cordova.plugins.email.isAvailable( function (isAvailable) { alert('Service is not available'); } ); } })
and this is my click:
<a ng-click="sendMail()"> <i class="icon ion-android-forums"></i> send mail </a>
This code works well in $ ionicPlatform, but does not work in a separate controller file.
source share