내부에서 상위 구성 요소의 변수에 접근 설정Angular2 라우터 - 내가 열어하려고 할 때 다음과 같은 모듈이 라우팅 한 아이 컴퍼넌트
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,
}
]
}
]
}
];
은 그래서 http://localhost:4200/persons/3/edit
Angular2 먼저 PersonsComponent은 PersonDetailInfoComponent 다음 PersonDetailComponent 다음로드합니다.
이제 PersonDetailComponent에서 나는 백엔드에서 사람 정보를 검색하는 서비스 요청을 받았고 검색된 Person 정보를 PersonDetailInfoComponent 내부에서도 사용하고 싶습니다.
그럼 내 질문은 Angular2가 부모 구성 요소 (예 : PersonDetailInfoComponent 내부의 PersonDetailComponent.personModelfrom에 액세스)에서 변수에 액세스 할 수있는 inbuilt 방식을 제공하는지 여부입니다.
이 작업을 수행하는 데있어 "올바른"방법이 있습니까? 아니면 모두가 자신 만의 맞춤 솔루션을 구현하게 될 것입니까? 또한이 기능을 쉽게 사용할 수없는 경우 Angular2 이후 버전에서이 기능을 제공 할 계획이 있습니까?
환불 및 사전에 부탁드립니다.
P. 다음과 같이
내 종속/버전
은 다음과 같습니다"@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"