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

Method constructor

packages/router/src/directives/router_link.ts:376–419  ·  view source on GitHub ↗
(
    private router: Router,
    private route: ActivatedRoute,
    @Attribute('tabindex') private readonly tabIndexAttribute: string | null | undefined,
    private readonly renderer: Renderer2,
    private readonly el: ElementRef,
    private locationStrategy?: LocationStrategy,
  )

Source from the content-addressed store, hash-verified

374 private readonly reactiveRouterState = inject(ReactiveRouterState);
375
376 constructor(
377 private router: Router,
378 private route: ActivatedRoute,
379 @Attribute('tabindex') private readonly tabIndexAttribute: string | null | undefined,
380 private readonly renderer: Renderer2,
381 private readonly el: ElementRef,
382 private locationStrategy?: LocationStrategy,
383 ) {
384 const tagName = el.nativeElement.tagName?.toLowerCase();
385 this.isAnchorElement =
386 tagName === 'a' ||
387 tagName === 'area' ||
388 !!(
389 // Avoid breaking in an SSR context where customElements might not
390 // be defined.
391 (
392 typeof customElements === 'object' &&
393 // observedAttributes is an optional static property/getter on a
394 // custom element. The spec states that this must be an array of
395 // strings.
396 (
397 customElements.get(tagName) as {observedAttributes?: string[]} | undefined
398 )?.observedAttributes?.includes?.('href')
399 )
400 );
401
402 if (typeof ngDevMode !== 'undefined' && ngDevMode) {
403 effect(() => {
404 if (
405 isUrlTree(this.routerLinkInput()) &&
406 (this._fragment() !== undefined ||
407 this._queryParams() ||
408 this._queryParamsHandling() ||
409 this._preserveFragment() ||
410 this._relativeTo())
411 ) {
412 throw new RuntimeError(
413 RuntimeErrorCode.INVALID_ROUTER_LINK_INPUTS,
414 'Cannot configure queryParams or fragment when using a UrlTree as the routerLink input value.',
415 );
416 }
417 });
418 }
419 }
420
421 /**
422 * Modifies the tab index if there was not a tabindex attribute on the element

Callers

nothing calls this directly

Calls 4

AttributeInterface · 0.90
effectFunction · 0.90
isUrlTreeFunction · 0.90
getMethod · 0.65

Tested by

no test coverage detected