link()
ts
const link: (...values: [string, string]) => DirectiveResult<typeof LinkDirective>;
Links an element to a given path. If the element is an anchor, it will set the href
attribute, otherwise it will set a data-href
attribute and a role="link"
attribute. It will also add a click handler to the element that will navigate to the given path, then.
Parameters
values
...[string
, string
]
Returns
DirectiveResult
<typeof LinkDirective
>
Examples
html
<a ${link('/home')}>Home</a>
html
<button ${link('?menu-visible=1')}>Home</button>
html
<custom-button ${link('/login', 'button')}>Home</custom-button>