Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dynamic parameter in href option in Aurelia Routing config.map

Tags:

aurelia

This seems like a really simple issue, but it's driving me crazy...

Does anyone know how I can specify a dynamic :id parameter in the href routing configuration option?

The following unfortunately doesn't work:

    config.map([
        // ... default parameterless routing here
        {
            route:[':id/request'],
            moduleId:'processes/bdd/request/request',
            name:'Request', title:'Request', href:`#/bdd/request/${id}/request`, settings:{type:'Request', icon:''}, nav:true,
        },
        {
            route:[':id/requestAuth'],
            moduleId:'processes/bdd/request/requestauthorization',
            name:'RequestAuthorization', title:'Request Authorization', href:`#/bdd/request/${id}/requestAuth`, settings:{type:'Request', icon:''}, nav:true,
        },
        // ... some additional mappings here
    ]);
like image 675
Themos Avatar asked Mar 09 '23 19:03

Themos


1 Answers

The href property is static. If you want to generate a route for a link using this route, you could use the route-href custom attribute like this:

 route-href="route: request; params.bind: { id: someProp }"

Note that I changed the route name to be camelCase (all lowercase since it is one word here) to match the route naming convention.

like image 197
Ashley Grant Avatar answered Apr 08 '23 14:04

Ashley Grant