更改URL而不刷新AngularJS中的页面

I am working on a project in which I have requirement to change the URL after a specific page, because there are some credentials in the URL.

I did that by using location.Replace() method. It changed the URL in address bar and reloaded the page, but I don't want that.

For example in my URL abc.com/app/XXXX/#/app/inbox I want to remove XXXX/ on the replacement.

I used location.replace(abc.com/app/#/app/inbox). It replaced the url, but also reloaded the page. I don't want my page to be reloaded on URL change.

In your app.js file add this code. It's adding an extra parameter to $location.path().

app.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]);
    };
}]);

then in your controller call $location.path() as

$location.path('/users/' +$scope.userid, false);