title: Login page in AngularJS
body: <p>I've got a web application where all interactions require logging in. I see at least two ways of implementing a login page view in AngularJS.</p>
  
  <p>One is to use a separate view: let say I'm using <a href="https://github.com/angular-ui/ui-router">angular-ui-router</a> and define a top-level view with two states: login and dashboard.</p>
  
  <pre><code>myApp.config(function($stateProvider, $urlRouterProvider) {
    $urlRouterProvider.otherwise("/login");
    $stateProvider
      .state('login', {
        url: "/login",
        templateUrl: "partials/login.html"
      })
      .state('mainpage', {
        url: "/mainpage",
        templateUrl: "partials/mainpage.html",
        controller: function($scope) {
          …
        }
      });
  </code></pre>
  
  <p>Second is to just make use of ng-if:</p>
  
  <pre><code>&lt;span ng-if="loggedin"&gt;
    … my main page …
  &lt;/span&gt;
  &lt;span ng-if="!loggedin"&gt;
    … login page …
  &lt;/span&gt;
  </code></pre>
  
  <p>I see that the second option will easily allow users to link to specific sections of their pages, with the login page showing up as necessary automatically, whereas the first option will require me to code some redirection stuff to make this happen.</p>
  
  <p>However, for some reason I feel the first option is cleaner, even if I cannot provide any reasonable arguments now.</p>
  
  <p>I'm starting with AngularJS now, so I don't have enough experience to decide on any of these options. Which one is more desirable?</p>