Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular UI Router - How to use $uiViewScroll in code

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!

like image 761
Michael Avatar asked Aug 07 '26 22:08

Michael


1 Answers

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
        }

    });
like image 71
Sten Muchow Avatar answered Aug 11 '26 20:08

Sten Muchow



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!