I want to AngularJS Change Path Without Reloading, look http://joelsaupe.com/programming/angularjs-change-path-without-reloading/
in core.js:
'use strict';
angular.module('App',['ngRoute'])
.run(['$route', '$rootScope', '$location', function ($route, $rootScope, $location) {
var original = $location.path;
$location.path = function (path, reload) {
if (reload === false) {
var lastRoute = $route.current;
var un = $rootScope.$on('$locationChangeSuccess', function () {
$route.current = lastRoute;
un();
});
}
return original.apply($location, [path]);
};
}]);
In controller:
angular.module('App')
.controller('DetailController', ['$scope', '$location', function($scope) {
$scope.changeURL = function(){
console.log("IN changeURL");
$location.path('/sample/gfshdfdsf', false);
};
}]);
If invoke changeURL, it will occur error:ReferenceError: $location is not defined
Can somebody help me? Thanks!