Links in Aurelia

Creating links in Aurelia is really easy:

<a route-href="route: dashboard">Dashboard</a>

This generates something like: http://localhost:8080/dashboard

By using route-href we can easily map the url to a router path in the router configuration.

What if we want to pass some extra parameters? To generate something like: http://localhost:8080/dashboard?id=49

<a route-href="route: dashboard; params.bind:{id:49};">Dashboard</a>

And if we want to get something like: http://localhost:8080/dashboard/49

<a route-href="route:dashboard; params.bind:{id:49}; {options: absolute}">Dashboard</a>

How about doing redirections? Also easy:

    { id: 10}


    { id: },
    { absolute: true } // absolute urls

Simple and easy :)

Pedro Luz
A personal blog by Pedro Luz about coding, coding, habit building, and a few things more.(Psst... I am open to opportunities.)
Reach out to me on your favorite social :)© 2020 Pedro Luz