title: Angular Factory Local Variables
body: <p>This question has probably  something to do with me not grasping the factory concept in angular, i have the following factory:</p>
  
  <pre><code>.factory('utils', ['api', '$log', '$q',
      function(api, $log, $q) {
  
      var utils = {};
      var cart = {
          products: new Array(),
          payment: 'cash'
      };
  
  
      /**
       * Access the shopping cart
       */
      utils.getCart = function() {
          return this.cart;
  
      };
  
  
      return utils;
  
  }
  ]);
  </code></pre>
  
  <p>The problem is that the local variable <em>cart</em> is not persistent, when i try to access the factory from the controller <em>cart</em> is always undefined. I understand that <em>this.cart</em> refer to a field in the util object which is not the case, but how can i return the local variable.</p>