title: Angular2 pass data from CanActivate guard to Resolve resolver?
body: <p>I have a situation where I've been using a Resolve to pre-load some data from a remote source via an HTTP call prior to navigating to a component.  Now I need to implement some guard logic which requires that, depending on some conditions, that data be pre-loaded to verify some fields on it against the current user.</p>
  
  <p>I'd like to avoid making the exact same request to the backend in the <code>CanActivate</code> guard and then immediately afterwards in the <code>Resolve</code>.</p>
  
  <p>Is there some way I can access the route data from inside the <code>CanActivate</code> or the route config to temporarily override the resolver and just set the value on the data object since I've got what I'm about to request?</p>
  
  <p>I tried getting away with something as simple as</p>
  
  <pre><code>route.data['myData'] = value;
  </code></pre>
  
  <p>But this is an error because "object is not extensible".</p>
  
  <p>I also tried something like:</p>
  
  <pre><code>this.router.routerState.root.data['myData'] = value;
  </code></pre>
  
  <p>Which didn't create any errors, however the data hadn't survived into the <code>route.data</code> element of the <code>Resolve.resolve()</code> method.</p>
  
  <p>I'd like to avoid something too custom or hacky like temporarily storing the object on the Service like some sort of cache.  Is there any standard mechanism for transferring data between internal router elements to support advanced pre-fetching and stuff like data ownership checks?</p>
  
  <p><strong>EDIT</strong>
  The routerState does work if you inject the Router into the constructor of the <code>Resolve</code> class, and access it the same way.  But this needs to be cleared afterwards otherwise it does persist between navigation calls.</p>