Changing route doesn't scroll to top in the new page

后端 未结 18 2051
北恋
北恋 2020-11-29 15:11

I've found some undesired, at least for me, behaviour when the route changes. In the step 11 of the tutorial http://angular.github.io/angular-phonecat/step-11/app/#/phon

18条回答
  •  情歌与酒
    2020-11-29 15:38

    Using angularjs UI Router, what I'm doing is this:

        .state('myState', {
            url: '/myState',
            templateUrl: 'app/views/myState.html',
            onEnter: scrollContent
        })
    

    With:

    var scrollContent = function() {
        // Your favorite scroll method here
    };
    

    It never fails on any page, and it is not global.

提交回复
热议问题