From my current path location i want to check my previous path location, how it is possible in angularjs
1 Answer
welcome to Stackoverflow. it would be nice if you could provide some further details on your question, as in its current state, your post is likely to get closed for showing no reaseach efforts etc. I strongly recommend to you the lecture of this nice 'How to ask' page
$scope.$on('$locationChangeStart',function(evt, absNewUrl, absOldUrl) {
var hashIndex = absOldUrl.indexOf('#');
var oldRoute = absOldUrl.substr(hashIndex + 2);
History.lastRoute = oldRoute;
});
Service
globalModule.factory('History',function(){
return{
lastRoute: ''
}
});
Will get you the url string (and therefore the name of the route) when HTML5Mode is false.
However, you are quite unclear about what you actually want to achieve. If you do need some other informations about the route, please tell us first which router you are using.