title: Angular 2: pass a value to the route data resolve
body: <p>I'm trying to write a <code>DataResolver</code> service that will allow the Angular 2 router to preload data before initializing my component.</p>
  
  <p>The resolver needs to call different API endpoints to fetch data appropriate to the route being loaded.  Rather than having a resolver for each of my many components, I'm building one generic resolver. Thus, I'd like to pass custom input in the route definition that points to the correct endpoint. For instance, consider these routes:</p>
  
  <p><strong>app.routes.ts</strong></p>
  
  <pre><code>appRoutes = [
    {
       path: 'project/:id',
       component: ProjectComponent,
       resolve: { data: DataResolver }
    },
    {
       path: 'store/:id',
       component: StoreComponent,
       resolve: { data: DataResolver }
    }
  ]
  </code></pre>
  
  <p>In the first instance, the resolver will need to call <code>/path/to/resource1/id</code>. In the second case, <code>/path/to/resource2/id</code>. Ideally, I would pass the endpoint as an argument in the route definition that would then be available in the <code>DataResolver</code> constructor.</p>
  
  <p>Can this be done with a generic resolver class?</p>
  
  <p><code>Angular 2.0.1</code> written in <code>Typescript 2.0.3</code></p>