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

Method onClick

packages/router/src/directives/router_link.ts:479–522  ·  view source on GitHub ↗
(
    button: number,
    ctrlKey: boolean,
    shiftKey: boolean,
    altKey: boolean,
    metaKey: boolean,
  )

Source from the content-addressed store, hash-verified

477 '$event.metaKey',
478 ])
479 onClick(
480 button: number,
481 ctrlKey: boolean,
482 shiftKey: boolean,
483 altKey: boolean,
484 metaKey: boolean,
485 ): boolean {
486 const urlTree = this._urlTree();
487
488 if (urlTree === null) {
489 return true;
490 }
491
492 if (this.isAnchorElement) {
493 if (button !== 0 || ctrlKey || shiftKey || altKey || metaKey) {
494 return true;
495 }
496
497 if (typeof this.target === 'string' && this.target != '_self') {
498 return true;
499 }
500 }
501
502 const browserUrl = this.browserUrl();
503 const extras = {
504 skipLocationChange: this.skipLocationChange,
505 replaceUrl: this.replaceUrl,
506 state: this.state,
507 info: this.info,
508 // TODO: Remove conditional spread once all consumers handle `browserUrl`.
509 // Having this property always set broke some tests in G3.
510 ...(browserUrl !== undefined && {browserUrl}),
511 };
512 // navigateByUrl is mocked frequently in tests... Reduce breakages when
513 // adding `catch`
514 this.router.navigateByUrl(urlTree, extras)?.catch((e) => {
515 this.applicationErrorHandler(e);
516 });
517
518 // Return `false` for `<a>` elements to prevent default action
519 // and cancel the native behavior, since the navigation is handled
520 // by the Router.
521 return !this.isAnchorElement;
522 }
523
524 /** @docs-private */
525 ngOnDestroy(): any {}

Callers

nothing calls this directly

Calls 3

browserUrlMethod · 0.80
catchMethod · 0.45
navigateByUrlMethod · 0.45

Tested by

no test coverage detected