B
B
boozzd2015-06-10 09:03:58
JavaScript
boozzd, 2015-06-10 09:03:58

How to scroll to an AngularJs ID?

In the application I use angular-ui-router:

$stateProvider
     .state('page', {
        url: '/:node',
        templateUrl: "app/page/page.html",
        controller: "PageCtrl"
      })
      .state('page.comments', {
        url: '#disqus_comment',
        templateUrl: 'app/page/page.html',
        controller: 'PageCtrl'
      });
$locationProvider.hashPrefix('!');

When I click on a link in the page.comment format (localhost.loc/#!/test#disqus_comment), I get to the page, but the scroll to the element with the identifier does not work.
Found the function $anchorScroll(); which works, for example, if you bind it to a button, but calling it in the controller does not bring any results.
And this is not working:
$rootScope.$on('$stateChangeSuccess', function () {
      $anchorScroll();
    });

Are there any ideas? Thank you.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Valentin Dubrovsky, 2015-06-10
@boozzd

https://github.com/angular-ui/ui-router/wiki/Quick...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question