MCPcopy Index your code
hub / github.com/angular/angular / RouterLink

Class RouterLink

packages/router/src/directives/router_link.ts:190–583  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

188 },
189})
190export 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

Callers

nothing calls this directly

Calls 13

computeHrefMethod · 0.95
injectFunction · 0.90
linkedSignalFunction · 0.90
InputInterface · 0.90
signalFunction · 0.90
HostListenerInterface · 0.90
computedFunction · 0.90
isUrlTreeFunction · 0.90
inputFunction · 0.85
fragmentMethod · 0.80
queryParamsMethod · 0.80
createUrlTreeMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…