title: Issue in a declared factory: AngularJs
body: <pre><code>var app = angular.module('app',[]);
  
  //in the html, the following 2 files are attached.
  //          &lt;script src="lib/sockjs-0.3.4.min.js"&gt;&lt;/script&gt;
  //          &lt;script src="lib/vertxbus.min.js"&gt;&lt;/script&gt;
  
  app.factory('serverData',function(){
      var eb = new vertx.EventBus('http://xxx.xxx.xxx.xxx');
      var x = {};
      eb.send( "com.find.web.ed",{"Em":'user@find.com',"Pw":'123'}, 
          function(reply){
              x = reply;
          });
      var fact = {};
      fact.getData = function(){
          return x;
      };
  
      return fact;
  });
  
  app.controller('mainController',function($scope,serverData){
  
  });
  </code></pre>
  
  <h2>In the above code, i am trying to declare a factory to get data from  a vertex server. It is not working, can some one help.?</h2>
  
  <p>It is working well when It is used in a controller. See the code.</p>
  
  <pre><code>var app = angular.module('app',[]);
  
  app.controller('mainController',function($scope,$log){
  $rootScope.user = {user :'user@find.com',password :'123'};
  $rootScope.reply = {};
  
  $scope.eb = new vertx.EventBus('http://100.100.100.100:8000');
  
  $scope.loginFunction = function(){
              $scope.eb.send( "com.find.web.ed", 
                  {"Em":$scope.user.user,"Pw":$scope.user.password},
                  function(reply){
                   $rootScope.reply = reply;
                   $log.warn($rootScope.reply);
  } 
  );
  }
  });
  </code></pre>