Conditional default route in Angular.js

How do I make Angular.js go to / route 1 by default if $ rootScope.isAdmin == true, but if isAdmin is false or doesn't exist - go to / route 2?

isAdmin is installed in the login controller:

.controller(
  'LoginController',
['$scope', '$rootScope', '$http', 'authService',
  ($scope, $rootScope, $http, authService) ->
    $scope.submit = ->
      try
        $http.post("/users/sign_in",
          user:
            email: @username
            password: @password
            remember_me: if @remember_me then 1 else 0
        ).success (response) ->
          $rootScope.isAdmin = response[0].is_admin
          authService.loginConfirmed()
      catch ex
        alert ex
])

      

+3


source to share





All Articles