angular.js - After viewing the details, the return list page does not stay at the original viewing place - the solution to the angularJS problem? Ask God for advice
黄舟
黄舟 2017-05-15 16:53:07
0
1
636

After viewing the details, the return list page does not stay where it was originally viewed - the solution to the angularJS problem? Ask God for advice

黄舟
黄舟

人生最曼妙的风景,竟是内心的淡定与从容!

reply all(1)
左手右手慢动作

If your list page is a paginated page, then you need to save the page number of the page, maybe in the URL, then when you return, read the page number from the URL and load the data of that page number.
If your list page is a very long page and you need to return to the original position, then you may need to abstract a service to record the user's position on this page, and read this every time you enter this page. service thenscrollTothat location.
If your list page has no pagination and is not very long, it is actually best to just go back to the top of the page.

For the case where the page is very long:

js// PagePosition Service
angular.module('app').factory('PagePosition', function() {
    var _top = 0;
    var _left = 0;

    return {
        getPosition: function() {
            return {
                top: _top,
                left: _left
            }
        },
        setPosition: function(top, left) {
            _top = top;
            _left = left;
        }
    }
});

Inject this service into the view or directive you need, modify the position in the user scroll event, read the position when returning to this page, and call scrollTo to position.

However, I suggest that if the page is too long, it is best to display your list in pages, because even if you can return to the previous position when returning, the user experience is quite poor.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template