erikringsmuth / app-router

Router for Web Components
https://erikringsmuth.github.io/app-router/
MIT License
610 stars 83 forks source link

Does app-router support dynamically created routes? #114

Open araad opened 9 years ago

araad commented 9 years ago

I'm trying to include a "template repeat" to dynamically create routes, even though they are being rendered, they are not triggering any change when the url is changed.

<app-router core-animated-pages transitions="slide-from-right">
    <template repeat="{{section in sections}}">
        <app-route path="/{{section.name}}">
            <template>
                <p>{{section.name}}</p>
            </template>
        </app-route>
    </template>
</app-router>

Is that not supported?

erikringsmuth commented 9 years ago

The <app-router> only looks for <app-route> elements that are direct children. https://github.com/erikringsmuth/app-router/blob/master/src/app-router.js#L205-L211

It works this way in case there are multiple nested routers so that the outer router doesn't use inner router's routes.