AngularJS ui-router, scroll to next step on state change

前端 未结 4 1714
攒了一身酷
攒了一身酷 2021-02-03 14:36

I\'m using UI-router in my app and I\'d like to so a simple \"scrollTo\" to an anchor when the URL/state changes. I don\'t want to load the next step from a template, or load a

4条回答
  •  终归单人心
    2021-02-03 14:59

    You can listen to $locationChangeSuccess, e.g.

    $rootScope.$on('$locationChangeSuccess', scrollBasedOnLocationChangeEvent);
    

    Basic example: http://angular-ui.github.io/ui-router/site/#/api/ui.router.router.$urlRouter

提交回复
热议问题