title: AngularJs : Attach a stateParams value to custom data in state objects
body: <p>I'm defining a page title in my state object as advised <a href="https://github.com/angular-ui/ui-router/wiki#attach-custom-data-to-state-objects" rel="nofollow noreferrer">here</a>.</p>
  
  <pre><code>$stateProvider
    .state('project', {
      url: '/projects/:origin/:owner/:name',
      template: '&lt;project&gt;&lt;/project&gt;',
      data : { pageTitle: 'Project page title'},
    });
  </code></pre>
  
  <p>so i can access it this way later on:</p>
  
  <pre><code>$state.current.data.pageTitle
  </code></pre>
  
  <p>Now ... What i'd like to do is that instead of having a fixed value as pageTitle i'd like to access one the stateParams.</p>
  
  <p><strong>BEWARE</strong>, below exemple is not working, this is the way i'd like it to work.</p>
  
  <pre><code>$stateProvider
    .state('project', {
      url: '/projects/:origin/:owner/:name',
      template: '&lt;project&gt;&lt;/project&gt;',
      data : { pageTitle: $stateParams.name},
    });
  </code></pre>
  
  <p>I could also use the attribute <strong>resolve</strong> :</p>
  
  <p>resolve: { title: 'Project page title' },</p>
  
  <p>For stateParams value i could do that:</p>
  
  <pre><code>resolve:{
      pageTitle: ['$stateParams', function($stateParams){
        return $stateParams.name;
      }]
  }
  </code></pre>
  
  <p>But then console.log($state.current.resolve.pageTitle); in my controller will return the entire function and not the result.</p>
  
  <p>What would be the proper way to do that?</p>
  
  <p><strong>UPDATE :</strong></p>
  
  <p>The thing which i didn't mention is that i use angularJs with ES6 and i use a modular architecture. 
  Therefore each component has its own scope. </p>
  
  <p>You can check my previous <a href="https://stackoverflow.com/questions/35500779/angularjs-child-state-return-parent-view">post</a> to have a better idea about the modular architecture i'm using.</p>
  
  <p>I'm building a breadcrumb grabbing the parent states (using the defined pageTitle). 
  Therefore defining the page title name in each module would be perfect.</p>
  
  <p>So i can decide if the page title would be a fixed value "My page title" or a stateParams value.</p>
  
  <p>Maybe this is totally wrong and this should not be done that way. Let me know if it is the case.</p>