This should help.
Thanks had just provided query string param. Update added below for route param. No direct way for route params other than to provide a back button. http://stackoverflow.com/questions/15175429/angularjs-getting-previous-route-path
<!DOCTYPE html>
<html ng-app="demo">
<head>
    <meta charset="UTF-8">
    <title>Ang</title>
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.2/angular.min.js"></script>
    <script src="angular-route.js"></script>
    <script>
        var app = angular.module("demo",['ngRoute']);
        app.config(function($routeProvider){
            $routeProvider
            .when("/",{
                template:"<div>{{id}}</div>",
                controller:function($scope){
                    $scope.id = "Home";
                }
            })
            .when("/demo",{
                template:"<div>{{id}}</div>",
                controller:function($scope){
                    $scope.id = "Demo";
                }
            })  
            .when("/demo/:name",{
                template:"<a href='' ng-click='back();'>Back</a><div>{{id}}</div>",
                controller:function($scope, $route,$routeParams,$location,$rootScope){
                    // Do the following for routeParams
                    // But now the back will not work. 
                    // So you might have to use a back button or provide link to url:/demo      
                    if($routeParams.name === 'ganesh'){$route.updateParams({name:'test'});}
                    $scope.back = function(){
                        $rootScope.back();
                    }
                    // Do the following for Query Params  (/demo?name=...) and ('/demo?name')
                    //console.log($routeParams.name);
                    //$scope.id = $location.search().name;
                    //if ($location.search().name === 'test'){$location.search('name', 'ganesh').replace()};
                }
            })  
            .otherwise("/");        
        }).run(function ($rootScope, $location) {
                var history = [];
                $rootScope.$on('$locationChangeStart', function() {
                    history.push($location.$$path);
                });
                $rootScope.back = function () {
                    var prevUrl = history.length > 2 ? history.splice(-3)[0] : "/";
                    console.log(prevUrl);
                    $location.path(prevUrl);
                };
        });
    </script>
</head>
<body>
    <div ng-view></div>
</body>
</html>