Search code examples
aurelia

How do you get the router name to use in a template inside a for navigation loop using Aurelia Framework


I need to get the router.name defined in the routes.

Code

 <li repeat.for="row of router.navigation" data=${row.name}
 </li>

The code above does not get the route name. I know all of the information I need is in the NavModel but I don't know how to access it in my above example using a for loop in the template


Solution

  • You're very close there. What you're looking for is:

    ${row.config.name}
    

    You can see the full route meta-data available by logging it out to the console in the app.js view-model:

    enter image description here

    This is also useful for if you what to include anything from the route settings in your nav.