I\'ve just upgraded to ui-router 0.2.8
from 0.2.0
and I\'ve noticed that when the state changes, the scroll position jumps to the top of te child <
If you wanted to do this with views conditionally, you could place this in the controller view like so:
.state('exampleState', {
url: '/exampleURL',
controller: 'ExampleCtrl as examplectrl',
onEnter: function($rootScope) {
$rootScope.$on('$viewContentLoaded',function(){
jQuery('html, body').animate({ scrollTop: 0 }, 200);
});
}
}).
or optionally which might keep your state.js file cleaner place the above in the controller for given view:
function ExampleCtrl ($scope, $rootScope) {
$rootScope.$on('$viewContentLoaded',function(){
jQuery('html, body').animate({ scrollTop: 0 }, 200);
});
}
Hope this helps someone, please let me know if I'm missing something. I used the latter and works great for me.