简体   繁体   English

我如何获得后退按钮以在AngularJS中返回多个页面

[英]How do I get the back button to go back multiple pages in AngularJS

I am currently working on an application and I need the back button to go back multiple pages. 我当前正在开发一个应用程序,需要返回按钮才能返回多个页面。 I am familiar with the history.back function as shown below. 我熟悉history.back函数,如下所示。

//go back to the last view
$rootScope.goBack = function(){
    history.back();
  }

However, this only goes back one page. 但是,仅返回一页。 Is there anyway for the history to go back further than one step? 无论如何,历史可以追溯到更远的一步吗? If so, how can I implement this? 如果是这样,我该如何实施?

Thank you! 谢谢!

EDIT: I figured I would also share that you can you use the back() feature not only in the html but also in your controller by using $rootScope.back(-2); 编辑:我想我也将分享您可以通过$ rootScope.back(-2)不仅在html中而且还可以在控制器中使用back()功能;

Just tell it how far to go back: 只要告诉它要回去多远:

$rootScope.goBack = function(){
    history.go(-3);
}

It's really as simple as that. 就这么简单。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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