title: restricting and redirecting based on a boolean value in an angular application
body: <p>I would like to restrict and redirect access to certain routes in my angular app. I realize there were other questions similar to this, but because angular and firebase keep evolving, some of the earlier solutions no longer work and I would like to have the simplest possible solution as my current goal is not to make a production app, but an app that works.</p>
  
  <p>I can log in and log out and every time I log in I set a rootscope variable to true and every time I log out I set that variable to false. Given this, how can I restrict my routes and redirect to the login page when the user isn't logged in?</p>
  
  <pre><code>angular
    .module('angularappApp', [
      'ngCookies',
      'ngResource',
      'ngRoute',
      'ngSanitize',
      'firebase'
    ])
    .config(function ($routeProvider) {
      $routeProvider
        .when('/', {
          templateUrl: 'views/main.html',
          controller: 'MainCtrl',
          controllerAs: 'main'
        })
        .when('/chat', {
            templateUrl: 'views/chat.html',
            controller: 'ChatCtrl'
        })
        .when('/login', {
            templateUrl: 'views/login.html',
            controller: 'LoginCtrl'
        })
        .when('/register', {
            templateUrl: 'views/register.html',
            controller: 'RegisterCtrl'
        })
        .when('/about', {
          templateUrl: 'views/about.html',
          controller: 'AboutCtrl',
          controllerAs: 'about'
        })
        .when('/logout', {
            template: 'Loging out...',
            controller: 'LogoutCtrl'
        })
        .otherwise({
          redirectTo: '/'
        });
    }).constant('FBURL', 'https://dazzling-inferno-7746.firebaseio.com/');
  </code></pre>
  
  <p>This is my app.js file.</p>