Привет, я не могу передать свои данные от ребенка к родителю, используя @ ViewChild
У меня есть этот код от
админа layout.component.ts
@ViewChild(TribeComponent)
getRoute :TribeComponent;
ngAfterViewInit() {
console.log( this.getRoute);
this.message = this.getRoute.messagetwo;
console.log('Values on ngAfterViewInit():');
console.log("primaryColorSample:", this.message);
}
и код от
tribecomponent.ts
messagetwo:string = "true";
ошибка
TypeError: Cannot read property 'messagetwo' of undefined
at AdminLayoutComponent.push../src/app/layouts/admin-layout/admin-layout.component.ts.AdminLayoutComponent.ngAfterViewInit (admin-layout.component.ts:45)
at callProviderLifecycles (core.js:22416)
at callElementProvidersLifecycles (core.js:22390)
at callLifecycleHooksChildrenFirst (core.js:22380)
at checkAndUpdateView (core.js:23316)
at callViewAction (core.js:23548)
at execEmbeddedViewsAction (core.js:23511)
at checkAndUpdateView (core.js:23308)
at callViewAction (core.js:23548)
at execComponentViewsAction (core.js:23490)
первая консоль была неопределена console.log( this.getRoute);
вторая ошибка была выше console.log("primaryColorSample:", this.message);
Кстати, admin-layout является своего рода html-компонентом моего приложения, поэтому я использую выход маршрутизатора для перехода к компоненту Tribe. Это причина, по которой оно не может видеть племя своим ребенком?
Вот пример того, как работает мой макет Угловая панель аргона Creative Tim's