`anchorScroll` – how to toggle `url:#hash` on slide up?

In my html, i have a div, when the button show is clicked i am showing the div when user clicks back i am hiding.

I decided to focus on the div on show. for that i used anchorScroll. it works fine. while user click id updates my url from http://localhost:5000/ to http://localhost:5000/#bottom and focusing to element.

while the user clicks back the 2 time, i am not focusing back, reason is the http://localhost:5000/#bottom not changing back to http://localhost:5000/ – i guess strongly.

so how can i swtich back to previous state again?

here is my js :

$scope.galleryMenu = function (gallery) {

            $scope.galleryShow = !$scope.galleryShow;

            //focusing to bottom
            $location.hash('bottom'); //adds the hash
            $anchorScroll(); //focusing.


            $scope.batch = $scope.batch || {};
            $scope.totalGallerySlide = 0;

            for(var i = 0; i < $scope.allApps.length; i++) {
                $scope.batch['b'+$scope.totalGallerySlide] = $scope.batch['b'+$scope.totalGallerySlide] || [];
                $scope.batch['b'+$scope.totalGallerySlide].push($scope.allApps[i]);
                i%16 === 15 ? $scope.totalGallerySlide++ : null;
            }

            $scope.activeBatch = $scope.batch.b0;
            galleryMaker();
        }


Source: jquery

Leave a Reply