Skip to content

Instantly share code, notes, and snippets.

@jgentes
Created June 18, 2015 15:55
Show Gist options
  • Save jgentes/425c034179c22c9b769c to your computer and use it in GitHub Desktop.
Save jgentes/425c034179c22c9b769c to your computer and use it in GitHub Desktop.
ui-router state resolve with service injection
.state('person', {
url: "/{person}",
resolve: {
type: function (communityApi, $stateParams) {
console.log('output')
console.log(communityApi.getKey($stateParams.person))
return;
}
}
})
@jgentes
Copy link
Author

jgentes commented Jun 18, 2015

Also very nice:

$urlRouterProvider.otherwise(
    function($injector, $location, $state) {
        $injector.get('$state').go('dashboard');
    });

@jgentes
Copy link
Author

jgentes commented Jun 18, 2015

And:

$urlRouterProvider.otherwise(function($injector, $location){
  $injector.invoke(['$state', function($state) {
    $state.go('404');
  }]);
}); 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment