title: Angular Service To Set And Retrieve Object Between Controllers
body: <p>I been trying to set an service object from a http post response to a controller and getting it from another controller.<br>
  The tutorials I seen in SO or sites are focused more on getting it from HTML input to a controller and another controller getting the value.</p>
  
  <p>I would want to avoid using rootscope and I'm new to angular-js. </p>
  
  <p>First Controller(To Put Data1 &amp; Data2 in an object)</p>
  
  <pre><code>.controller('GetItem',function($scope, $http, $filter, $ionicPopup, $stateParams, $cordovaSQLite, $cordovaDatePicker, dataFactory){
      ...
      console.log(resp.data);
      var data1= resp.data.data1;
      var data2= resp.data.data2;
   }
  </code></pre>
  
  <p>2nd Controller (To get the object and retrieve data1 and data2)</p>
  
  <p>Some pointers would be deeply appreciated!</p>
  
  <p><strong>Update1:</strong> (Save Function Works but Get Function Returns EMPTY):</p>
  
  <pre><code>.service('StoreService',function(){
  
   var data1=[]; //{} returns me an empty object
  
   this.save=function(data1){
   alert('DATA: '+ data1); //able to retrieve string
   this.data1=data1;
  
   };
  
   this.getData1=function(){
   alert('DATA1: '+ data1); //unable to get string
   return data1;
  
   };
  })
  </code></pre>
  
  <p>This is the 2nd Controller which retrieve from service:</p>
  
  <pre><code> .controller('unlock', function($scope, $timeout, dataFactory, $stateParams,StoreService) {
  
    function test(){
      console.log(StoreService.getData1());
  </code></pre>
  
  <p>Update 2: (Working)
  Tomislav's plunker : <a href="http://plnkr.co/edit/srAphQhAYuBZL18MY1Kr?p=preview" rel="noreferrer">http://plnkr.co/edit/srAphQhAYuBZL18MY1Kr?p=preview</a></p>