在点击按钮时更改url,而无需在angularjs中重新加载页面

在点击按钮时更改url,而无需在angularjs中重新加载页面,angularjs,Angularjs,我目前正在使用location.hash,但似乎每次单击按钮时都会重新加载页面,是否有其他方法可以防止这种情况 这是我目前使用的代码 function jumpToAnchor(ID) { var newHash = 'group_' + ID; if ($location.hash() !== newHash) { $location.hash(newHash

我目前正在使用location.hash,但似乎每次单击按钮时都会重新加载页面,是否有其他方法可以防止这种情况

这是我目前使用的代码

 function jumpToAnchor(ID) {
           
            var newHash = 'group_' + ID;
            if ($location.hash() !== newHash) {
              
                $location.hash(newHash);
            }
            $anchorScroll(); 

        }