Skip to content

feat(router): Provide child routes access to parent route information #5330

@brandonroberts

Description

@brandonroberts

When using nested routes, I would like to set params at the top level and be able to access those params or other information in the child routes instead of adding the same params/data in each of the child routes.

@RouteConfig([
    { path: '/users/:id/...', component: Users, as: 'Users' }
])
class App {
}

@RouteConfig([
    { path: '/', component: Profile, as: 'Profile' },
    { path: '/stats', component: Stats, as: 'Stats' }
])
class Users {
    constructor(params: RouteParams) {
        // need access to Users ID route param
        this.id = params.parent.get('id');
    }
}

Plunk displays how its handled today.

http://plnkr.co/edit/v1Np3niVn3WNTZBvHQLf?p=preview

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions