title: Angularjs routing: Cannot read property 'path' of undefined
body: <p>I'm trying to trigger angularJS routing inside of a function in controller, but it throws back "Uncaught TypeError: Cannot read property 'path' of undefined". Can't really see where I missed $location injection, guess it's the reason.</p>
  
  <pre><code>var gameApp = angular.module('gameApp', ['ngRoute']);
  
  gameApp.config(function($routeProvider, $locationProvider, $provide) {
    $locationProvider.html5Mode(true);
    $routeProvider
  
    // route for the home page
    .when('/', {
      templateUrl : 'home.html',
      controller  : 'mainController'
    })
  
    // route for the game page
    .when('/game', {
      templateUrl : 'game.html',
      controller  : 'gameController'
    })
  
    // route for the game over page
    .when('/game-over', {
      templateUrl : 'game-over.html',
      controller  : 'mainController'
    })
  
    // default
    .otherwise({
      redirectTo: '/'
    });
  });
  </code></pre>
  
  <p>And part of my game controller when I'm using router</p>
  
  <pre><code>gameApp.controller('gameController', ['$scope', '$location', function($scope, $location){
      function gameLost($location){
          var check = false;
          console.log ('You lose! Your score is ')
          $location.path('/game-over');
  </code></pre>
  
  <p>}])</p>