title: Waiting for response from factory then proceed to service call
body: <p>I want the <code>service(MyService.postData)</code> to be call only after all the functionality in factory function(<code>MyFactory.getData</code>) is over. </p>
  
  <p>The return value from factory is always false or undefined and I get an error for sending the service call:</p>
  
  <p><strong>1.</strong> First am calling a function define in factory which is used for login in a user through a pop up template</p>
  
  <p><strong>2.</strong> Secondly, only if user is logged in, the following service call will be made:</p>
  
  <pre><code>    //My AngularJS controller is something like 
      myApp.controller("firstCtrl", function($scope, MyFactory, MyService) { 
          $scope.value = MyFactory.getData();
          if($scope.value){
              MyService.postData("url",params).then(function(){
                  //do something
              });
  
      });
  
      //My AngularJS factory is something like
      myApp.factory("MyFactory",function(){
           return {
               getData: function(){
                  //open pop up to login 
                  //close pop up get confirmation
                  return true;
               }
      });
  
      //My AngularJS service is something like
      myApp.service("MyService",function($http){
      //do something
      });
  </code></pre>