MCPcopy Create free account
hub / github.com/angular/angular / constructor

Method constructor

packages/router/src/directives/router_link.ts:407–448  ·  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

405 private readonly reactiveRouterState = inject(ReactiveRouterState);
406
407 constructor(
408 private router: Router,
409 private route: ActivatedRoute,
410 @Attribute('tabindex') private readonly tabIndexAttribute: string | null | undefined,
411 private readonly renderer: Renderer2,
412 private readonly el: ElementRef,
413 private locationStrategy?: LocationStrategy,
414 ) {
415 const tagName = el.nativeElement.tagName?.toLowerCase();
416 this.isAnchorElement =
417 tagName === 'a' ||
418 tagName === 'area' ||
419 !!(
420 // Avoid breaking in an SSR context where customElements might not
421 // be defined.
422 typeof customElements === 'object' &&
423 // observedAttributes is an optional static property/getter on a
424 // custom element. The spec states that this must be an array of
425 // strings.
426 (
427 customElements.get(tagName) as {observedAttributes?: string[]} | undefined
428 )?.observedAttributes?.includes?.('href')
429 );
430
431 if (typeof ngDevMode !== 'undefined' && ngDevMode) {
432 effect(() => {
433 if (
434 isUrlTree(this.routerLinkInput()) &&
435 (this._fragment() !== undefined ||
436 this._queryParams() ||
437 this._queryParamsHandling() ||
438 this._preserveFragment() ||
439 this._relativeTo())
440 ) {
441 throw new RuntimeError(
442 RuntimeErrorCode.INVALID_ROUTER_LINK_INPUTS,
443 'Cannot configure queryParams or fragment when using a UrlTree as the routerLink input value.',
444 );
445 }
446 });
447 }
448 }
449
450 /**
451 * 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