title: Making promises in modules
body: <p>I try to make facebook registration module in my app. Facebook API is faster than my Angular controller, so promise should be used here. The problem is that $q seems to be an empty object and defer function is undefined.</p>
  
  <p>module:</p>
  
  <p>var module = angular.module('app.facebook', []);
      module.constant("fbAppId", 'herecomesmycode');</p>
  
  <pre><code>module.factory('facebook', FacebookAPI);
  FacebookAPI.$inject = ['$ionicLoading', '$q', '$ionicPlatform', '$state', 'authService', 'datacontext', '$location'];
  
  function FacebookAPI(UserService, $q, $ionicLoading, fbAppId, $state, authService, datacontext, $location) {
      return {
          fbLoginSuccess: fbLoginSuccess,
          fbLoginError: fbLoginError,
          getFacebookProfileInfo: getFacebookProfileInfo,
          fbLogin: fbLogin,
          fbRegister: fbRegister
  
      };
  </code></pre>
  
  <p>and here $q.defer is undefined: </p>
  
  <pre><code>    function fbRegister() {
  
          console.log($q.defer);
          if (!cordova) {
              facebookConnectPlugin.browserInit(fbAppId);
          }
          var data;
          facebookConnectPlugin.getLoginStatus(function (response) {
              if (response.status !== 'connected') {
                  facebookConnectPlugin.login(["email"],
                      function(response) {
                          data = getApiData();
                      },
                      function(response) {
                      });
              } else {
                  data = getApiData();
              }
          });
      }
  </code></pre>
  
  <p>Without using promise, it gets fast from API but all variables I want to fill with values from API, are initiated before API finishes and are undefined.</p>