Reputation: 9247
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);
And when i back on page to have something like this : www.test.com?d=123
Upvotes: 9
Views: 13091
Reputation: 3618
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.
For Example to go 2 index back
this._location.back(2);
Example to go back with queryParams
this.router.navigate(['/test2', { id: 12321313}]);
Check for angular 2 declaration function location.back() inside @angular\common.js
class Location {
/* Navigates back in the platform's history.*/
/* @return {?} */
back() { this._platformStrategy.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
Upvotes: 4