I use Angular scrollTo and anchorScroll as follows:
app.controller('TestCtrl', function($scope, $location, $anchorScroll) { $scope.scrollTo = function(id) { $location.hash(id); $anchorScroll(); } }); <a ng-click="scrollTo('foo')">Foo</a> <div id="foo">Here you are</div>
My problem is that when I click the link, the page scrolls down, but in 50% of cases the page reloads because the hash changes in the URL.
How can I prevent an Angular page from reloading?
Update: I found that here
https://groups.google.com/forum/?fromgroups=#!msg/angular/BY2ekZLbnIM/MORF-z2vHnIJ
what
The $location service broadcasts a $locationChangeStart event. You can observe that and call event.preventDefault() to stop the navigation. Nice!
can someone tell how to observe this event and prevent by default
source share