Scroll up after changing view

Asked

Viewed 45 times

0

I’m using angular in my system

I’m changing the views with the command $state.go('main.shops.cart.success');

But the problem is when mute to view the scroll continues down. I would like when it changes the view the scroll went to the top of the page.

How could I do that?

  • We need to see the composition of the code in order to have a starting point.

  • What do you need to see? @Bsalvo

1 answer

1

Will what you want to do is this: window.scrollTo(0, 0)?

According to that answer: https://stackoverflow.com/a/15007296/6882194

I think you can use:

$scope.$on('$locationChangeSuccess', function(event) {
    window.scrollTo(0, 0);
});

Browser other questions tagged

You are not signed in. Login or sign up in order to post.