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

前端 未结 4 1712
攒了一身酷
攒了一身酷 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:42

    Using

    • $anchorScroll
    • and ui-router's onenter callback

    You can do something like this:

    $stateProvider.state("step1", {
      template: 'template.html',
      controller: ...,
      onEnter: function(){
          $location.hash('step1');
          $anchorScroll();
      }
    });
    ...
    

提交回复
热议问题