From d9a22dae4f9fe477efd3b07d2964453434dec3f7 Mon Sep 17 00:00:00 2001 From: Dzmitry Shylovich Date: Sun, 8 Jan 2017 01:04:18 +0300 Subject: [PATCH] fix(router): RouterLink mirrors input `target` as attribute Closes #13837 --- modules/@angular/router/src/directives/router_link.ts | 2 +- modules/@angular/router/test/integration.spec.ts | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/@angular/router/src/directives/router_link.ts b/modules/@angular/router/src/directives/router_link.ts index 3b54226c6d..abf9da123b 100644 --- a/modules/@angular/router/src/directives/router_link.ts +++ b/modules/@angular/router/src/directives/router_link.ts @@ -139,7 +139,7 @@ export class RouterLink { */ @Directive({selector: 'a[routerLink]'}) export class RouterLinkWithHref implements OnChanges, OnDestroy { - @Input() target: string; + @HostBinding('attr.target') @Input() target: string; @Input() queryParams: {[k: string]: any}; @Input() fragment: string; @Input() preserveQueryParams: boolean; diff --git a/modules/@angular/router/test/integration.spec.ts b/modules/@angular/router/test/integration.spec.ts index a251df2685..5f7a3d2eae 100644 --- a/modules/@angular/router/test/integration.spec.ts +++ b/modules/@angular/router/test/integration.spec.ts @@ -998,6 +998,7 @@ describe('Integration', () => { const native = fixture.nativeElement.querySelector('a'); expect(native.getAttribute('href')).toEqual('/team/33/simple'); + expect(native.getAttribute('target')).toEqual('_self'); native.click(); advance(fixture); @@ -2710,7 +2711,8 @@ function expectEvents(events: Event[], pairs: any[]) { } } -@Component({selector: 'link-cmp', template: `link`}) +@Component( + {selector: 'link-cmp', template: `link`}) class StringLinkCmp { }