I have the following module routing setup
const personsRoutes: Routes = [
{
path: '',
redirectTo: '/persons',
pathMatch: 'full'
},
{
path: 'persons',
component: PersonsComponent,
children: [
{
path: '',
component: PersonListComponent
},
{
path: ':id',
component: PersonDetailComponent,
children: [
{
path: '',
redirectTo: 'info',
pathMatch: 'full'
},
{
path: 'info',
component: PersonDetailInfoComponent,
},
{
path: 'edit',
component: PersonDetailEditComponent,
},
{
path: 'cashflow',
component: PersonDetailCashflowComponent,
}
]
}
]
}
];
So when I try to open up http://localhost:4200/persons/3/edit
Angular2 would first load PersonsComponent followed by PersonDetailComponent followed by PersonDetailInfoComponent.
Now in PersonDetailComponent I have a service request to retrieve the person info from the backend and I would like to use the retrieved Person information inside the PersonDetailInfoComponent as well.
So my question is whether Angular2 provides an inbuilt way where I can access variables from the parent components (ex: access PersonDetailComponent.personModelfrom inside PersonDetailInfoComponent).
Is there an Angular-endorsed "right" way of doing this or is it one of those things where everyone will end up implementing their own custom solution? Also, in case this is not readily available, are there any plans to provide this functionality down the road in a later version of Angular2?
Cheers and thank in advance.
P.S.
My dependencies/versions are as follows:
"@angular/common": "2.0.0",
"@angular/compiler": "2.0.0",
"@angular/core": "2.0.0",
"@angular/forms": "2.0.0",
"@angular/http": "2.0.0",
"@angular/platform-browser": "2.0.0",
"@angular/platform-browser-dynamic": "2.0.0",
"@angular/router": "3.0.0",
"core-js": "^2.4.1",
"rxjs": "5.0.0-beta.12",
"ts-helpers": "^1.1.1",
"zone.js": "^0.6.23"