Angular ui-router scroll to top, not to ui-view

后端 未结 10 1372
情话喂你
情话喂你 2020-12-12 16:00

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 <

10条回答
  •  攒了一身酷
    2020-12-12 16:53

    Since $stateChangeSuccess seems not to be available anymore in current AngularJS (as 1.2.x) I changed Rishul Mattas example to the following which works fine for me:

    app.run(function ($rootScope) {
      $rootScope.$on('$viewContentLoaded',function(){
        jQuery('html, body').animate({ scrollTop: 0 }, 200);
      });
    });
    

提交回复
热议问题