title: $cordovaContacts from within AngularJS Service
body: <p>I am trying to use $cordovaContacts service defined in the <a href="http://ngcordova.com" rel="nofollow">ngCordova module</a>. I am trying to get the phone contacts in a service so I can use it across controllers. </p>
  
  <p>Service.js</p>
  
  <pre><code>angular.module("services", ['ngCordova'])
    .factory("ContactManager", function($cordovaContacts) {
      var contacts; //variable that holds contacts, returned from getContacts
  
       return {
          getContacts: function() {
            var options = {};
             options.filter = "";
             options.multiple = true;
  
             //get the phone contacts
             $cordovaContacts.find(options).then(function(result) {
               contacts = result;
               }, function(err) {
             });
            return contacts;
          }
       }
    });
  </code></pre>
  
  <p>Controller.js</p>
  
  <pre><code>angular.module("controllers", ['services'])
    .controller("ContactCtrl", function(ContactManager) {
       $scope.contacts = ContactManager.getContacts(); //this doesn't get set
    });
  </code></pre>
  
  <p>The problem is that '$scope.contacts' does not get set inside the controller. However, when put the service code inside the controller directly without using the service, the code works. I have been trying to figure out what the problem is. Please help!</p>