Angular UI Router - How to use $ uiViewScroll in Code

I am new to AngularJS and Angular UI Router. I want to decorate and call Angular ui router $ uiViewScroll from javascript code but can't figure out how to do it. Can someone please help me understand this?

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

Thanks in advance!

+3


source to share


1 answer


Here is a small example of how you can run it.



'use strict';

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

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

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

            $uiViewScroll(element);

        };

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

    });

      

+7


source







All Articles