Skip to content

Instantly share code, notes, and snippets.

@matejkramny
Created October 26, 2013 19:58
Show Gist options
  • Save matejkramny/7173798 to your computer and use it in GitHub Desktop.
Save matejkramny/7173798 to your computer and use it in GitHub Desktop.
Logout angular ui-router
app.config(function($stateProvider, $urlRouterProvider, $locationProvider) {
$stateProvider.state('logout', {
url: '/logout',
controller: function($scope, $route) {
$route.reload()
}
})
@harmon
Copy link

harmon commented Mar 13, 2014

Thanks man, I would've been struggling with this for an hour or so!

Copy link

ghost commented Apr 30, 2014

Same here, thank you!

Angular is telling me that I need to include angular-route/$routeProvider. It would be awesome if there were a way to accomplish this without requiring angular-route.

@reynaldot
Copy link

If you want to avoid including the angular-route module I guess you could do:

controller: function($window) {
  $window.location.reload();
}

@MichaelJCole
Copy link

Hey, thanks for this. It helped me alot. Here's the version I used:

  // Sign IN
  .state('sign-out', {
    url: '/sign-out',
    controller: function($state, User) {
      User.signOut();
      $state.go('welcome');
    },
    data: {
      requireLogin: false,
    }
  })

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