How to make Angular.js to go to /route1 by default if the $rootScope.isAdmin==true, but if isAdmin is false or does not exist - go to /route2 ?
isAdmin is set in a 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
])