3

I am new to AngularJS and Angular UI Router. I am wanting to decorate and call angular ui router's $uiViewScroll from javascript code but cannot figure out how to do so. Can someone please help me figure this out?

For the decoration part I have found: Angular ui-router scroll to top, not to ui-view

Thanks in advance!

Community
  • 1
  • 1
Michael
  • 308
  • 3
  • 12

1 Answers1

7

Here is a small example how you can get it to fire.

'use strict';

angular.module('Directives.ScrollTop', [])

    .directive('scrollTop', function($uiViewScroll) {

        var linker = function (scope, element, attr) {

            $uiViewScroll(element);

        };

        return {
            restrict: 'A',
            link: linker
        }

    });
Sten Muchow
  • 6,623
  • 4
  • 36
  • 46