Skip to content

Instantly share code, notes, and snippets.

@vespertilian
Last active August 10, 2016 14:45
Show Gist options
  • Save vespertilian/2fd51b9069d18c2ce286e1ad138bc05b to your computer and use it in GitHub Desktop.
Save vespertilian/2fd51b9069d18c2ce286e1ad138bc05b to your computer and use it in GitHub Desktop.
NG2 router learnings
## Employee key is avaliable on child components when parent component is just a path
// :employeeKey will be avaliable on:
// this.route.snapshot.params['employeeKey'] && this.route.params.subscribe(values => console.log(values))
// on the **EmployeeDetails** and **Dependants** component
{
path: 'employee/:employeeKey',
canActivate: [AuthGuard],
children: [
{ path: '', component: EmployeeDetails, resolve: { url: DataResolver}},
{ path: 'dependants', component: Dependants},
]
}
## Employee key not avaliable on child components when parent path has a component
// :employeeKey will be avaliable on:
// this.route.snapshot.params['employeeKey'] && this.route.params.subscribe(values => console.log(values))
// on the **Employee** component
### :employeeKey WILL NOT BE AVALIABLE on **EmployeeDeatils and Dependants**
{
component: Employee, //THIS IS THE DIFFERENCE
path: 'employee/:employeeKey',
canActivate: [AuthGuard],
children: [
{ path: '', component: EmployeeDetails, resolve: { url: DataResolver}},
{ path: 'dependants', component: Dependants},
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment