title: Redirect to another page with Angular
body: <p>I'm very very new to Angular so I would like to apologize for this question up front.</p>
  
  <p>I have this Angular script that sends a POST request and in the fail section I would like to redirect the user to another page.
  This is the structure of the site</p>
  
  <p>-login folder<br>
  &emsp;&emsp;js folder<br>
  &emsp;&emsp;&emsp;&emsp; controllers.js<br>
  &emsp;&emsp;login.html<br>
  &emsp;&emsp;login.css<br>
  -index.html</p>
  
  <p>My Angular code id in controllers.js. I use the code in the login.html. I need to redirect the user from login.html to index.html. This unfortunately doesn't work, when it goes in the error part of the code it doesn't redirect the user.</p>
  
  <p>Here is the code:</p>
  
  <pre><code>var app = angular.module('WebApp', []);
  
  app.controller('myCtrl', function($scope, $http, $location) {
    $scope.login = function($location){
      $scope.incorrectPass = false;
      $http.post('service link', {'email': $scope.username, 'password': $scope.password, 'UUID': 'dknasklaxcaosdhdajkshnjk', 'platform': 1})
      .success(function(data, status, headers, config) {
        alert("request success");
      })
      .error(function(data, status) {
        $scope.$apply(function() { $location.path("/index.html"); });
      });
    }
  }); 
  </code></pre>