title: preventing access to certain routes based on some condition - angularjs
body: <p>I am writing a small angular js app with different views. Some views are available to all users but few views are available to only logged in user. I have a small login form on top of my main page [note that there is no separate login screen]. </p>
  
  <p>Everything was working fine till here,till then I noticed that even though all the views are not available on my screen initially and will get loaded only once the user logs in. But if the user knows the url of the restricted views , he can bypass the login process.</p>
  
  <p>I have found this stackoverflow question as something very similar to my problem <a href="https://stackoverflow.com/questions/11541695/angular-js-redirecting-to-a-certain-route-based-on-condition">Redirecting to a certain route based on condition</a>. Please see the accepted answer.</p>
  
  <p>But the issue here is that I don't have a separate login screen , so I can't use this code snippet given in the accepted answer</p>
  
  <pre><code>if ( next.templateUrl == "partials/login.html" ) {
            // already going to #login, no redirect needed
          } else {
            // not going to #login, we should redirect now
            $location.path( "/login" );
          }
  </code></pre>
  
  <p>How can I achieve the same solution with an integrated login form since I don't have a separate url for my login screen?</p>