title: Redirect to a login page if the user is not yet logged in Angular JS
body: <p>How can I prevent user enter App url's if he doesn't logged.</p>
  
  <p>App.js:</p>
  
  <pre><code>var MTApp = angular.module('MTApp', ['MEControllers','ui.router','services']);
  
      MTApp.config(function($stateProvider, $urlRouterProvider) {
          $urlRouterProvider.otherwise('/');
  
          $stateProvider
           .state('/', {
                  url: '/',
                  templateUrl: 'login.html'})             
              .state('login-app', {
                  url : '/Login',
                  templateUrl : 'login.html'})
  
             .state('input-parameters', {
              url : '/Parameters',
              templateUrl : 'parameters.html'});
      })
  
  main.js:
  
      var MEControllers = angular.module('MEControllers',[]);
      MEControllers.controller('LoginAppCtrl', LoginAppCtrl);
      MEControllers.controller('RequestCtrl', RequestCtrl);
  
      function LoginAppCtrl($scope, $http,utilities,$location,$rootScope) {           
              var self = this;
  
              self.request = {
                       user: '',
                       password:''
              }
              self.postprocess = function(){
                  //self.request.values = self.request.values.split(",");
              }
              self.submitRequest = function(){
                  self.postprocess();
                  console.log(self.request);
                  $http({
                      method : 'POST',
                      url : url,
                      headers: {'Content-Type': 'application/json'},
                      data : self.request
                  }).success(function(data, status, headers, config) {
  
                      if (data.status) {
                          // successfull login
                      //  User.isLogged = true;
                      //  User.username = data.user;
                      //  $rootScope.loggedInUser = $scope.user;
                          $location.path("/Parameters");
                      }
                      else {
                      //  User.isLogged = false;
                          //User.username = '';
                      }   
  
                  }).error(function(data, status, headers, config) {
                      alert('Invalid Login Details');
                  });
  
              }
  
              this.validate = function(){
                  console.log(self.request);
  
  
              }
          }
  
          function RequestCtrl($scope, $http,utilities,$location) {
              var self = this;            
              self.request = {
  
              }
              self.postprocess = function(){
  
              }
              self.submitRequest = function(){
                  self.postprocess();
                  console.log(self.request);
                  $http({
                      method : 'POST',
                      url : url,
                      headers: {'Content-Type': 'application/json'},
                      data : self.request
                  }).success(function(data, status, headers, config) {
  
                      utilities.setOutput(data);                    
                      console.log(data);
  
  
                  }).error(function(data, status, headers, config) {
                      alert('Error!');
                  });
  
              }
  
              this.validate = function(){
                  console.log(self.request);
  
  
              }
          }
  </code></pre>
  
  <p>How can I get indocation if user log-in? 
  Moreover How can I prevent user to enter pages through url, how can I hide the url?</p>