Angular 2: Prevent Router Adding to History

We have a client who is iFraming in our application on his website. They don’t want the navigation bar in our application to affect the navigation of the back button for their site.

We tried several methods, including using messages to send messages, so that the iFrame contacts the parent window whenever the history.back () function runs.

My question is, is there an easy way not to affect browser history when using an Angular 2 router. As far as I know, I could not find anything in the Angular 2 documentation of the extended router: https://angular.io/docs/ts/latest/ guide / router.html

+7
javascript angular browser-history iframe angular2-routing
source share
1 answer

Turns out there is a built-in way for routing Angular 2 to skip adding state to the story. We really found that it checks random properties inside the intellisense editor.

Our routing code should only:

this.router.navigate([`/myPage/${this.Id}`], { relativeTo: this.route });

in

this.router.navigate([`/myPage/${this.Id}`], { relativeTo: this.route, skipLocationChange: true });

+10
source share

All Articles