Class RouterLink

Custom element extending the HTMLAnchorElement. This element provides a declarative way to invoke the Router.navigate method within the bounds of the RouterOutlet, while maintaining compatibility with SSR/SEO aspects of SPAs. This is achieved by rewriting its href against the RouterOutlet.baseHref and intercepting the default browser behavior when onclicked.

Example

A router-link:

<a href="/example" is="router-link">Example</a>

See

Router

Hierarchy

Constructors

Properties

observedAttributes: string[] = ...

Array of attribute names that should be observed for changes, which will trigger the Component.attributeChangedCallback. This element only observes its href attribute.

onclick: ((event) => void) = ...

Overridden onclick handler, preventing the default browser behavior and invoking Router.navigate instead.

Type declaration

router: Router

Factored-in router property linking the Router.

Decorator

Factor

Methods

  • This method is called whenever this element's href attribute is added, removed or changed. The next attribute value is used to determine whether to Router.rebase the href.

    Parameters

    • _name: string

      The _name of the changed attribute (ignored).

    • Optional _prev: string

      The _previous value of the changed attribute (ignored).

    • Optional next: string

      The next value of the changed attribute.

    Returns void

Generated using TypeDoc