如何返回带参数的上一页? [英] How to return to previous page with parameters?
问题描述
我想使用一些参数返回上一页.任何建议,我该怎么做?
I want to return to previous page with some parameters. Any suggestion how can i do that?
import {Location} from '@angular/common';
returnToPreviousPage(){
this._location.back();
}
所以我想要的是这样的东西:
So what i want is something like this :
this._location.back(id:123);
当我返回页面时显示如下内容: www.test.com?d=123
And when i back on page to have something like this : www.test.com?d=123
推荐答案
在这里,如果您使用 this._location.back()
返回,则只能将索引传递给此函数.您想从浏览器历史记录中返回多少索引.
Here if you are using the this._location.back()
to go back you can pass only the index to this function. How much index you want to go back from browser history.
例如返回2个索引
this._location.back(2);
示例以返回queryParams
this.router.navigate(['/test2', { id: 12321313}]);
检查 @angular \ common.js
class Location {
/* Navigates back in the platform's history.*/
/* @return {?} */
back() { this._platformStrategy.back(); }
}
InShort您正在尝试的事情 this._location.back(2)
的工作方式与window.history.back();相同.并仅接受要从浏览器历史记录中返回的索引值
InShort the thing what you are trying this._location.back(2)
work same as window.history.back(); and accept only the index value you want to go back from browser history
这篇关于如何返回带参数的上一页?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!