diff --git a/modules/@angular/common/src/location/location_strategy.ts b/modules/@angular/common/src/location/location_strategy.ts index 5e8bd79f82..4a3f5f423b 100644 --- a/modules/@angular/common/src/location/location_strategy.ts +++ b/modules/@angular/common/src/location/location_strategy.ts @@ -28,7 +28,7 @@ import {UrlChangeListener} from './platform_location'; * @stable */ export abstract class LocationStrategy { - abstract path(includeHash: boolean): string; + abstract path(includeHash?: boolean): string; abstract prepareExternalUrl(internal: string): string; abstract pushState(state: any, title: string, url: string, queryParams: string): void; abstract replaceState(state: any, title: string, url: string, queryParams: string): void; diff --git a/modules/@angular/router/src/router.ts b/modules/@angular/router/src/router.ts index 0429164b41..1ed6a86ad5 100644 --- a/modules/@angular/router/src/router.ts +++ b/modules/@angular/router/src/router.ts @@ -276,7 +276,7 @@ export class Router { return new Promise((resolvePromise, rejectPromise) => { let updatedUrl: UrlTree; let state: RouterState; - let navigationIsSuccessful; + let navigationIsSuccessful: boolean; applyRedirects(url, this.config) .mergeMap(u => { updatedUrl = u; @@ -494,6 +494,7 @@ class ActivateRoutes { const currRoot = this.currState ? this.currState._root : null; pushQueryParamsAndFragment(this.futureState); + advanceActivatedRoute(this.futureState.root); this.activateChildRoutes(futureRoot, currRoot, parentOutletMap); } diff --git a/modules/@angular/router/test/router.spec.ts b/modules/@angular/router/test/router.spec.ts index a394e15a85..1a559232b2 100644 --- a/modules/@angular/router/test/router.spec.ts +++ b/modules/@angular/router/test/router.spec.ts @@ -518,10 +518,28 @@ describe('Integration', () => { it('should support top-level link', fakeAsync( inject([Router, TestComponentBuilder], (router: Router, tcb: TestComponentBuilder) => { - let fixture = tcb.createFakeAsync(AbsoluteLinkCmp); + const fixture = tcb.createFakeAsync(RelativeLinkInIfCmp); advance(fixture); - expect(fixture.debugElement.nativeElement).toHaveText('link'); + router.resetConfig( + [{path: 'simple', component: SimpleCmp}, {path: '', component: BlankCmp}]); + + router.navigateByUrl('/'); + advance(fixture); + expect(fixture.debugElement.nativeElement).toHaveText(' '); + const cmp = fixture.debugElement.componentInstance; + + cmp.show = true; + advance(fixture); + + expect(fixture.debugElement.nativeElement).toHaveText('link '); + const native = fixture.debugElement.nativeElement.querySelector('a'); + + expect(native.getAttribute('href')).toEqual('/simple'); + native.click(); + advance(fixture); + + expect(fixture.debugElement.nativeElement).toHaveText('link simple'); }))); it('should support query params and fragments', @@ -731,13 +749,13 @@ describe('Integration', () => { advance(fixture); expect(location.path()).toEqual('/team/22'); - let successStatus; + let successStatus: boolean; router.navigateByUrl('/team/33').then(res => successStatus = res); advance(fixture); expect(location.path()).toEqual('/team/33'); expect(successStatus).toEqual(true); - let canceledStatus; + let canceledStatus: boolean; router.navigateByUrl('/team/44').then(res => canceledStatus = res); advance(fixture); expect(location.path()).toEqual('/team/33'); @@ -1017,6 +1035,16 @@ class DummyLinkWithParentCmp { class RelativeLinkCmp { } +@Component({ + selector: 'link-cmp', + template: + `