I know that you can hide the URL when routing using this.router.navigate(["/Pages"], { skipLocationChange: true });
but when i use window.open("/Pages")
it has the URL.
Is there any way to hide the URL when using window.open()
or a way to use the angular2 router to open the URL in a new tab?
You can inject the Location
like this:
constructor(private readonly location: Location) {
//...
}
And then in ngOnInit()
run this:
public ngOnInit(): void {
this.location.replaceState("/");
}
This replaced the URL in the browser with the URL you specify in replaceState()
.
Found an easy way in the end. history.pushState({},"Edit","http://localhost:4200/");
works fine for what im after.
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.