title: How to access data from my controller in a state
body: <p>What is the best way to stop a user from going to a state if there is no data for that state? I need to redirect the user to /featured if there is no data in one of the other states.</p>
  
  <p>I thought that I could check the controller for data first and then redirect using $state.go if the data was null, but I can't find an example of how to access data in a controller inside of an onEnter event</p>
  
  <p>I think a code example should sum it up:</p>
  
  <pre><code>fseControllers.config(function($stateProvider, $urlRouterProvider){
  
    $urlRouterProvider.otherwise("/featured");
  
    $stateProvider
      .state('featured', {
          url: "/featured",
          templateUrl: "featured-template"
      })
  
      .state('friends', {
          url: "/friends",
          templateUrl: "friends-template",
          controller: 'FseController',
          onEnter: function(){
              // Here I want to redirect to /featured if no data in controller
          }
      })
  
      .state('stories', {
          url: "/stories",
          templateUrl: "stories-template"
      })
  
      .state('events', {
          url: "/events",
          templateUrl: "events-template"
      })
  })
  </code></pre>