Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(router_link): add skipLocationChange and replaceUrl inputs #12850

Merged
merged 1 commit into from Nov 15, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 13 additions & 5 deletions modules/@angular/router/src/directives/router_link.ts
Expand Up @@ -89,11 +89,13 @@ import {UrlTree} from '../url_tree';
*/
@Directive({selector: ':not(a)[routerLink]'})
export class RouterLink {
private commands: any[] = [];
@Input() queryParams: {[k: string]: any};
@Input() fragment: string;
@Input() preserveQueryParams: boolean;
@Input() preserveFragment: boolean;
@Input() skipLocationChange: boolean;
@Input() replaceUrl: boolean;
private commands: any[] = [];

constructor(
private router: Router, private route: ActivatedRoute,
Expand All @@ -120,7 +122,9 @@ export class RouterLink {
queryParams: this.queryParams,
fragment: this.fragment,
preserveQueryParams: toBool(this.preserveQueryParams),
preserveFragment: toBool(this.preserveFragment)
preserveFragment: toBool(this.preserveFragment),
skipLocationChange: toBool(this.skipLocationChange),
replaceUrl: toBool(this.replaceUrl),
});
}
}
Expand All @@ -138,12 +142,14 @@ export class RouterLink {
@Directive({selector: 'a[routerLink]'})
export class RouterLinkWithHref implements OnChanges, OnDestroy {
@Input() target: string;
private commands: any[] = [];
@Input() queryParams: {[k: string]: any};
@Input() fragment: string;
@Input() routerLinkOptions: {preserveQueryParams: boolean, preserveFragment: boolean};
@Input() preserveQueryParams: boolean;
@Input() preserveFragment: boolean;
@Input() skipLocationChange: boolean;
@Input() replaceUrl: boolean;
private commands: any[] = [];
private subscription: Subscription;

// the url displayed on the anchor element.
Expand Down Expand Up @@ -195,12 +201,14 @@ export class RouterLinkWithHref implements OnChanges, OnDestroy {
queryParams: this.queryParams,
fragment: this.fragment,
preserveQueryParams: toBool(this.preserveQueryParams),
preserveFragment: toBool(this.preserveFragment)
preserveFragment: toBool(this.preserveFragment),
skipLocationChange: toBool(this.skipLocationChange),
replaceUrl: toBool(this.replaceUrl),
});
}
}

function toBool(s?: any): boolean {
if (s === '') return true;
return !!s;
}
}
4 changes: 4 additions & 0 deletions tools/public_api_guard/router/index.d.ts
Expand Up @@ -232,7 +232,9 @@ export declare class RouterLink {
queryParams: {
[k: string]: any;
};
replaceUrl: boolean;
routerLink: any[] | string;
skipLocationChange: boolean;
urlTree: UrlTree;
constructor(router: Router, route: ActivatedRoute, locationStrategy: LocationStrategy);
onClick(): boolean;
Expand Down Expand Up @@ -262,11 +264,13 @@ export declare class RouterLinkWithHref implements OnChanges, OnDestroy {
queryParams: {
[k: string]: any;
};
replaceUrl: boolean;
routerLink: any[] | string;
routerLinkOptions: {
preserveQueryParams: boolean;
preserveFragment: boolean;
};
skipLocationChange: boolean;
target: string;
urlTree: UrlTree;
constructor(router: Router, route: ActivatedRoute, locationStrategy: LocationStrategy);
Expand Down