3

I'm trying to dynamically generate a route-href in a list of items. I basically have this:

this.items = [
    {
        name: 'Foo',
        route: 'item',
        routeParams: {
            id: 1
        }
    },
    {
        name: 'Bar',
        route: 'item',
        routeParams: {
            id: 2
        }
    }
];

And in my view:

<ul>
    <li repeat.for="item of items">
        <a route-href="route: ${item.route}; params.bind: ${item.routeParams}">
            ${item.name}
        </a>
    </li>
</ul>

But Aurelia tells me:

aurelia-logging-console.js:54 ERROR [route-href] Error: A route with name 'undefined' could not be found. Check that `name: 'undefined'` was specified in the route's config

If I print the ${item.route} and ${item.routeParams} they do contain the correct values:

<ul>
    <li repeat.for="item of items">
        <a route-href="route: ${item.route}; params.bind: ${item.routeParams}">
            ${item.name} ${item.route} ${item.routeParams}
        </a>
    </li>
</ul>

Why? :/

1 Answer 1

8

The correct syntax is:

<a route-href="route.bind: item.route; params.bind: item.routeParams">...</a>

More information at http://aurelia.io/hub.html#/doc/article/aurelia/framework/latest/cheat-sheet/7

1
  • Thanks :) params.bind=${item.routeParams} was a typo, I had params.bind: ${item.routeParams} in my code. route.bind was missing though and solved it.
    – powerbuoy
    Commented Jul 14, 2016 at 18:51

Not the answer you're looking for? Browse other questions tagged or ask your own question.