diff --git a/modules/@angular/router/src/directives/router_link.ts b/modules/@angular/router/src/directives/router_link.ts index f92659f1a0..13b7fe3193 100644 --- a/modules/@angular/router/src/directives/router_link.ts +++ b/modules/@angular/router/src/directives/router_link.ts @@ -59,7 +59,7 @@ export class RouterLink implements OnDestroy { @HostBinding() href: string; @HostBinding('class.router-link-active') isActive: boolean = false; - constructor(@Optional() private _routeSegment: RouteSegment, private _router: Router) { + constructor(private _routeSegment: RouteSegment, private _router: Router) { // because auxiliary links take existing primary and auxiliary routes into account, // we need to update the link whenever params or other routes change. this._subscription = diff --git a/modules/@angular/router/src/recognize.ts b/modules/@angular/router/src/recognize.ts index 028e20a0a7..0054c57422 100644 --- a/modules/@angular/router/src/recognize.ts +++ b/modules/@angular/router/src/recognize.ts @@ -8,7 +8,6 @@ import {ComponentResolver} from '@angular/core'; import {DEFAULT_OUTLET_NAME} from './constants'; import {reflector} from '@angular/core'; -// TODO: vsavkin: recognize should take the old tree and merge it export function recognize(componentResolver: ComponentResolver, rootComponent: Type, url: UrlTree): Promise { let matched = new _MatchResult(rootComponent, [url.root], {}, rootNode(url).children, []); diff --git a/modules/@angular/router/src/router_providers_common.ts b/modules/@angular/router/src/router_providers_common.ts index 429201f4f7..df412a3f5d 100644 --- a/modules/@angular/router/src/router_providers_common.ts +++ b/modules/@angular/router/src/router_providers_common.ts @@ -1,6 +1,7 @@ import {OpaqueToken, ComponentResolver} from '@angular/core'; import {LocationStrategy, PathLocationStrategy, Location} from '@angular/common'; import {Router, RouterOutletMap} from './router'; +import {RouteSegment} from './segments'; import {RouterUrlSerializer, DefaultRouterUrlSerializer} from './router_url_serializer'; import {ApplicationRef} from '@angular/core'; import {BaseException} from '@angular/core'; @@ -18,6 +19,7 @@ export const ROUTER_PROVIDERS_COMMON: any[] = /*@ts2dart_const*/[ deps: /*@ts2dart_const*/ [ApplicationRef, ComponentResolver, RouterUrlSerializer, RouterOutletMap, Location], }, + /*@ts2dart_Provider*/ {provide: RouteSegment, useFactory: (r) => r.routeTree.root, deps: [Router]} ]; function routerFactory(app: ApplicationRef, componentResolver: ComponentResolver, diff --git a/modules/@angular/router/test/integration_spec.ts b/modules/@angular/router/test/integration_spec.ts index 52ae1d85fc..c025e55ad2 100644 --- a/modules/@angular/router/test/integration_spec.ts +++ b/modules/@angular/router/test/integration_spec.ts @@ -39,6 +39,7 @@ export function main() { provide(RouterUrlSerializer, {useClass: DefaultRouterUrlSerializer}), RouterOutletMap, provide(Location, {useClass: SpyLocation}), + provide(RouteSegment, {useFactory: (r) => r.routeTree.root, deps: [Router]}), provide(Router, { useFactory: (resolver, urlParser, outletMap, location) => new Router( @@ -224,6 +225,13 @@ export function main() { expect(getDOM().getAttribute(native, "href")).toEqual("/team/33/simple(aux:simple2)"); }))); + + it("should support top-level link", + fakeAsync(inject([Router, TestComponentBuilder], (router, tcb) => { + let fixture = tcb.createFakeAsync(LinkCmp); + advance(fixture); + expect(fixture.debugElement.nativeElement).toHaveText('link'); + }))); } }); } diff --git a/modules/@angular/router/test/recognize_spec.ts b/modules/@angular/router/test/recognize_spec.ts index 1c2bf2bf57..06d2cb59fa 100644 --- a/modules/@angular/router/test/recognize_spec.ts +++ b/modules/@angular/router/test/recognize_spec.ts @@ -20,7 +20,7 @@ import {DefaultRouterUrlSerializer} from '../src/router_url_serializer'; import {DEFAULT_OUTLET_NAME} from '../src/constants'; export function main() { - ddescribe('recognize', () => { + describe('recognize', () => { it('should handle position args', inject([AsyncTestCompleter, ComponentResolver], (async, resolver) => { recognize(resolver, ComponentA, tree("b/paramB/c/paramC/d")) diff --git a/modules/@angular/router/testing/router_testing_providers.ts b/modules/@angular/router/testing/router_testing_providers.ts index f047a00e97..b08a498623 100644 --- a/modules/@angular/router/testing/router_testing_providers.ts +++ b/modules/@angular/router/testing/router_testing_providers.ts @@ -1,6 +1,7 @@ import {SpyLocation} from '@angular/common/testing'; import {Location} from '@angular/common'; import {Router, RouterOutletMap} from '../src/router'; +import {RouteSegment} from '../src/segments'; import {RouterUrlSerializer, DefaultRouterUrlSerializer} from '../src/router_url_serializer'; import {Component, ComponentResolver} from '@angular/core'; @@ -24,4 +25,5 @@ export const ROUTER_FAKE_PROVIDERS: any[] = /*@ts2dart_const*/ [ deps: /*@ts2dart_const*/ [ComponentResolver, RouterUrlSerializer, RouterOutletMap, Location] }, + /*@ts2dart_Provider*/ {provide: RouteSegment, useFactory: (r) => r.routeTree.root, deps: [Router]} ];