Issue 1:
I'm submitting a ... (check one with "x")

[x] bug report => search github for a similar issue or PR before submitting

Current behavior

When CanDeactivate cancels Location.forward() routing history is 1 item ahead.

Workflow

Home -- navigate to --> Child 1
Child 1 -- navigate to --> Child 2
Child 2 -- navigate to --> Child 3 (CanDeactivate returned true)
Child 3 -- location.back() --> Child 2
Child 2 -- location.forward() --> Child 2 (navigation canceled CanDeactivate returned false)
Child 2 -- location.back() --> Child 2 (should be Route 1)

Expected behavior

Home -- navigate to --> Child 1
Child 1 -- navigate to --> Child 2
Child 2 -- navigate to --> Child 3 (CanDeactivate returned true)
Child 3 -- location.back() --> Child 2
Child 2 -- location.forward() --> Child 2 (navigation canceled CanDeactivate returned false)
Child 2 -- location.back() --> Child 1 (expected)

Minimal reproduction of the problem with instructions

http://plnkr.co/edit/PbKRj7v1B1tRVXRSrEup?p=preview

Click button Child1

Click button Child2

Click button Child3

Click button Back

Click button Forward

Click button Back

Expected behavior is to see Child1 but it's still Child2

Issue 2:
I'm submitting a ... (check one with "x")

[X ] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior

Currently, I have a deactivation guard on a route which will return false or true depending on a condition. To get to this guarded route, the user must pass though 3 navigation step. Now, once on the guarded route, when using location.back(), the guard is called. If it returns true, the previous route is loaded. If the guard returns false, the navigation is cancelled. But if we redo a Location.back() after a failed navigation, the previous route that will be loaded will be 2 steps in the history instead of 1 (user perception).

Workflow

Main -- navigate to --> Route 1
Route 1 -- navigate to --> Route 2
Route 2 -- navigate to --> Route 3
Route 3 -- location.back() --> guard returns true --> Route 2
Route 2 -- navigate to --> Route 3
Route 3 -- location.back() --> guard returns false --> Route 3
Route 3 -- location.back() --> guard returns true --> Route 1 (should be Route 2)

Expected behavior

An expected behavior for a user would be that navigating back brings back to the previous routed page.

Workflow

Main -- navigate to --> Route 1
Route 1 -- navigate to --> Route 2
Route 2 -- navigate to --> Route 3
Route 3 -- location.back() --> guard returns true --> Route 2
Route 2 -- navigate to --> Route 3
Route 3 -- location.back() --> guard returns false --> Route 3
Route 3 -- location.back() --> guard returns true --> Route 2 (expected)

Minimal reproduction of the problem with instructions

Plnkr

Click button Nav to route1

Click button Nav to route2

Click button Nav to route3

Click button Block Nav Back

Click button Nav back

BOGUE: The location.back() routed on Route1 instead of Route2

Personnal investigation

After some investigation, I saw that in routerState$.then (router.ts line 752) this logic used when navigationIsSuccessful == false is pretty simply but it is the actual cause of this bug. Basically, when a deactivation guard is hit, the location of the browser is already changed to the previous route. Which means that when the guard returns false, the routerState$ runs his logic and calls resetUrlToCurrentUrlTree(). At this point we can see that we replace the state of the current location. But by doing this, we loose that route in the history which means that in my plunker, if we click the block nav back 3 times and then click the nav back we will actually kill the application.

What is the motivation / use case for changing the behavior?

This is for me a pretty big bug since a guard that returns false breaks alters the current routing history. In the case of our application this breaks the workflow and brings wrong business scopes to a user.

Please tell us about your environment:

Windows 10, NPM, Nodejs, Visual Studio 2015 (using nodejs for typescript compilation)

Angular version: 2.3.3

Browser: [ all ]

Language: [TypeScript 2.0.10 | ES5]