title: TypeError: Cannot read property 'path' of undefined
body: <p>When the login is success I try to redirect other page in this case I have used a demo page index.html on sucess. But $location.path is not redirecting to the new page. I get the error as TypeError: Cannot read property 'path' of undefined.</p>
  
  <pre><code>module LoginModule {
      export class LoginController {
          username: string;
          password: string;
          static $inject = ['$http','$location'];
          constructor(private $http : ng.IHttpService,private $location : ng.ILocationService){
          }
          login() {
              this.$http({
                  method: 'POST',
                  url: 'https://localhost:8061/nada/login',
                  data : $.param({'username' : this.username, 'password' : this.password}),
                  headers: {
                      'Content-Type': 'application/x-www-form-urlencoded'
                  }}).success(function(data) {
                      this.$location.path("/success");
                     //alert("sucess");
                  }).error(function(error) {
                      JSON.parse(error);
                      alert('No access available.');
                     // console.log(result);
                  });
          }
      }
  
      angular.module('loginModule', ['ngRoute']).controller('LoginController', LoginModule.LoginController).config(['$routeProvider' ,function($routeProvider) {
          $routeProvider.
              when("/", {
              templateUrl: 'html/login.html'
          })
  
          .when("/success", {
              templateUrl: 'html/index.html',
              controller: 'clientsController'
          })
          .otherwise({redirectTo: '/'});
  
      }]);
  
  }
  </code></pre>
  
  <p>Is there something missing in my code. Also I have placed the routing part in the .config method can I move it to a class as I am trying to do it in typescript, if so how can I access that in mycontroller.</p>
  
  <p>I have login page that accepts the username and password. And makes a rest call</p>