title: Angular Factory Variables Won't Update - Instance gets old values
body: <p>I have a resource factory that builds objects for accessing our API. I use an environment variable to determine the base part of the URL - whether or not to include 'account/id' path segments when the admin user is 'engaging' a client account.</p>
  
  <p>The sessionStorage item that holds the 'engagedAsId' doesn't get read, though for instances created after engaging an account. It requires a full reload of the app to pick up that change. Here is the factory code:</p>
  
  <pre><code>myapp.factory('ResourceSvcFactory',
      ['$rootScope', '$resource', 
      function ($rootScope, $resource) {
  
      function ResourceSvcFactory (endpoint) {
          // vvv problem is here vvv
          var accountId = sessionStorage.getItem('engagedAsId');
          var apiPath = (accountId != null) 
              ? '/api/account/' + accountId + endpoint 
              : '/api' + endpoint;
  
          var Resource = $resource(apiPath+':id/',{
              // default params
              id:''
          },{
              // custom actions 
              update: {method: 'PUT'}
          });
  
          return Resource;
      }
  
      return ResourceSvcFactory;
  }]);
  
  myapp.factory('AssetsResource', ['ResourceSvcFactory', function (ResourceSvcFactory) {
  
      var endpoint = '/assets/';
      var Resource = ResourceSvcFactory(endpoint);
  
      return Resource;
  }]);
  </code></pre>
  
  <p>I implement this in my Controller like this:</p>
  
  <pre><code>myapp.controller('AssetGroupListCtrl', [ 'AssetgroupsResource', function (AssetgroupsResource) {
  
      var AssetGroups = AssetgroupsResource;
  
      // ... rest of controller
  }]);
  </code></pre>
  
  <p>When i run this it works fine. But, if i change the engaged status in the sessionStorage without a full reload, the instance in the controller does not pick up the new path.</p>
  
  <p>Is there a way to 'refresh' the instance? ...automatically?</p>