-
Notifications
You must be signed in to change notification settings - Fork 27.1k
Closed
Labels
area: routerfeatureLabel used to distinguish feature request from other issuesLabel used to distinguish feature request from other issuesopen for contributionsAn issue that is suitable for a community contributor (based on its complexity/scope).An issue that is suitable for a community contributor (based on its complexity/scope).
Milestone
Description
Which @angular/* package(s) are relevant/related to the feature request?
router
Description
Boolean inputs of RouterLink (and RouterLinkWithHref) should also accept empty string '' (and coerce that value to true).
Actually, such inputs are already coerced to boolean when they are read. Instead, they should be coerced by a setter to allow simpler template bindings, such as <a routerLink="/" skipLocationChange> instead of <a routerLink="/" [skipLocationChange]="true">. Currently, a compile-time error is thrown with the former syntax.
These inputs are: preserveFragment, skipLocationChange and replaceUrl.
Proposed solution
Add getter/setter to preserveFragment, skipLocationChange and replaceUrl fields of RouterLink and RouterLinkWithHref directives, for example:
private _skipLocationChange: boolean = false;
get skipLocationChange(): boolean { return this._skipLocationChange; }
@Input() set skipLocationChange(skipLocationChange: boolean | '' | null | undefined) {
this._skipLocationChange = coerceToBoolean(skipLocationChange);
}Alternatives considered
No alternative, more verbose template syntax is required.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
area: routerfeatureLabel used to distinguish feature request from other issuesLabel used to distinguish feature request from other issuesopen for contributionsAn issue that is suitable for a community contributor (based on its complexity/scope).An issue that is suitable for a community contributor (based on its complexity/scope).