简体   繁体   中英

Any alternative to window.history.back() as it repeats the visited page every time I go back

In angularjs, I have 3 pages, page1.html, page2.html, page3.html and have a function goback() which is

$scope.goback = function() {
    $window.history.back();
}

When I visit page1, page2, page3 and then again from page1,2,3 and again page1,2,3 and at last if I go back everyage repeats. means to say page3 then page 2 then page 1 and then again page3, 2, 1 and again page3, 2, 1.

I don't want to repeat these pages, if I press on goback(), it should go to page3, 2, 1 and then home.

Any help would be appreciated.

See if you are using $window.history.back(); then it will go through all your history.
It is good but if you dont want to go back like this then use data-ui-sref="" , so that you will return on desire page.
And if you want to go back on the basis of condition then add conditions like if it is page 1 then go back to some state of page1 and so on.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM