I want to have a default route in my sub-component (set with useAsDefault: true
) and to have parameters automatically passed to it. I cannot find anywhere in do
So I solved my problem in following way: I added a default route without params, and I immediately redirect from $routerOnActivate
public $routeConfig = [
{ path: '/', component: 'employeeListComponent', name: 'GroupRedirect', useAsDefault: true},
{ path: '/:group/:filter', component: 'employeeListComponent', name: 'Group'}
{ path: '/details/:employeeId/...', component: 'profileComponent', name: 'EmployeeProfile'},
]
and then in the controller:
public $routerOnReuse(route) {
if (!route.params.group) {
this.$router.navigate(['Group', { group: 'status', filter: 'active' }]);
}
}
As far as I know this is not supported. You can have a route with and without the parameter and then in the GroupDefault
component just navigate to Group
$routeConfig = [
{ path: '/group', component: 'employeeListComponentDefault', name: 'GroupDefault', useAsDefault: true}
{ path: '/:group/:filter', component: 'employeeListComponent', name: 'Group'},
{ path: '/details/:employeeId/...', component: 'profileComponent', name: 'EmployeeProfile'}
]
See also