I'm using AngularJS (MEAN.io stack) and i'm getting an annoying glitch related to scroll.
When user clicks on a link, the destination page takes the same scroll position than the origin page, instead of staying on top.
For fixing this weird behavior, I used next:
$rootScope.$on("$viewContentLoaded", function () {
$anchorScroll();
});
But this code makes every single page takes the scroll on top position, which is annoying as well because user must be able to go back and recover the previous scroll position.
Any suggestion? How can i get the desired result?
Thanks!
Edit --------------------
When i've tried to use the ng-view + autoscroll solution, it doesn't work for me and i don't know why.
This is the way i'm using it, in my default.html page which is served by the server:
<body ng-cloak class="ng-cloak" ng-class="{state: true, auth: authPage}" ng-controller="BodyController">
<div ng-include="'/system/views/header.html'"></div>
<section class="content">
<div data-ng-include="'/ceh-admin/views/adminShortcuts.html'"></div>
<div ng-view autoscroll="true">{% block content %}{% endblock %}</div>
</section>
<div data-ng-include="'/system/views/footer.html'"></div>
{% include '../includes/foot.html' %}
</body>
Something strange in my HTML code?