Last active
August 10, 2016 14:45
-
-
Save vespertilian/2fd51b9069d18c2ce286e1ad138bc05b to your computer and use it in GitHub Desktop.
NG2 router learnings
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## 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