Using ngCordova plugins without calling them in app.js?

My app is looking good, thanks to Ionic. All the core info is there and I'm just adding the frills - email, sharing, media (one of the functions is a metronome) and so on.

I can't get any plugins to work.

I've had success with a previous Ionic app but the plugins were all called from within

.run(function($ionicPlatform) {
   $ionicPlatform.ready(function() {
   }
}

and indeed the Statusbar plugin seems to working fine and it is called from within there.

I'm using the Side Menu starter with tabs built in btw.

My issue, I suppose, is that I've three controller files. main_ctrls.js - for the main app menu_ctrls.js - for the menu pages like feedback and email, analytics extras_ctrls.js - for the "extra" section with the metronome and so on.

I've put 'ngCordova' as a dependency in each module and called the plugin from within the controller with the ready function. Here is the email controller.

angular.module('menu.controllers', ['ngCordova'])

.controller('FeedCtrl', function($ionicPlatform, $scope, $cordovaEmailComposer) {

  $ionicPlatform.ready(function() {

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

    var email = {
      to: 'max@mustermann.de',
      cc: 'erika@mustermann.de',
      bcc: ['john@doe.com', 'jane@doe.com'],
      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 () {
      alert('Email discarded.');
    });
  })
});

I'm testing it on Android (Nexus 4 with Android 5.1) with Chrome inspect and I just get an error saying "Cannot read property 'isAvailable' of undefined". Needless to say, the alerts don't pop up.

This happens with all plugins called from within controllers in this way.

What am I doing wrong?

It seems like you are invoking the plugins before the cordova device ready is fired. In my angularjs application I have done the following. 1. Removed ng-app from html and did manual bootstrap through script 2. Added cordova.js file to the dependency. ( As the last dependency. After ng-cordova js) 3. Placed the cordova.js in the same folder as that of the index.html. (No explanation for why. From any other location, simply it was not getting added. May be something specific pertaining to cordova.) 4. Added the following script to the index.html

<script type="text/javascript" language="text/javascript"> 
$(document).ready(function() {
    document.addEventListener("deviceready", onDeviceReady, false);
}); 

onDeviceReady = function() {
    alert("hello!"); 
    angular.element(document).ready(function() {
    angular.bootstrap(document, ["main"]);
});
};
</script>

Here "main" is my main angularjs module. This ensures that the app is loaded only after the device ready event is fired by cordova and all cordova related functions are available. Specific to ionic I donot have anycode. May be the portion where ionic bootstraps the app can be put instead of angular.bootstrap.

My assumptions: you have added the plugins to your cordova project through the command

cordova plugin add <plugin-location>