| 188 | }, |
| 189 | }) |
| 190 | export class RouterLink implements OnChanges, OnDestroy { |
| 191 | private hrefAttributeValue = inject(new HostAttributeToken('href'), {optional: true}); |
| 192 | /** @docs-private */ |
| 193 | protected readonly reactiveHref = linkedSignal(() => { |
| 194 | // Never change href for non-anchor elements |
| 195 | if (!this.isAnchorElement) { |
| 196 | return this.hrefAttributeValue; |
| 197 | } |
| 198 | return this.computeHref(this._urlTree()); |
| 199 | }); |
| 200 | /** |
| 201 | * Represents an `href` attribute value applied to a host element, |
| 202 | * when a host element is an `<a>`/`<area>` tag or a compatible custom |
| 203 | * element. For other tags, the value is `null`. |
| 204 | */ |
| 205 | get href() { |
| 206 | return untracked(this.reactiveHref); |
| 207 | } |
| 208 | /** @deprecated */ |
| 209 | set href(value: string | null) { |
| 210 | this.reactiveHref.set(value); |
| 211 | } |
| 212 | |
| 213 | /** |
| 214 | * Represents the `target` attribute on a host element. |
| 215 | * This is only used when the host element is |
| 216 | * an `<a>`/`<area>` tag or a compatible custom element. |
| 217 | */ |
| 218 | @Input() set target(value: string | undefined) { |
| 219 | this._target.set(value); |
| 220 | } |
| 221 | get target(): string | undefined { |
| 222 | return untracked(this._target); |
| 223 | } |
| 224 | |
| 225 | /** |
| 226 | * @docs-private |
| 227 | * @internal |
| 228 | */ |
| 229 | protected _target = signal<string | undefined>(undefined); |
| 230 | |
| 231 | /** |
| 232 | * Passed to {@link Router#createUrlTree} as part of the |
| 233 | * `UrlCreationOptions`. |
| 234 | * @see {@link UrlCreationOptions#queryParams} |
| 235 | * @see {@link Router#createUrlTree} |
| 236 | */ |
| 237 | @Input() set queryParams(value: Params | null | undefined) { |
| 238 | this._queryParams.set(value); |
| 239 | } |
| 240 | get queryParams(): Params | null | undefined { |
| 241 | return untracked(this._queryParams); |
| 242 | } |
| 243 | // Rather than trying deep equality checks or serialization, just allow urlTree to recompute |
| 244 | // whenever queryParams change (which will be rare). |
| 245 | private _queryParams = signal<Params | null | undefined>(undefined, {equal: () => false}); |
| 246 | /** |
| 247 | * Passed to {@link Router#createUrlTree} as part of the |
nothing calls this directly
no test coverage detected
searching dependent graphs…