Posts

Showing posts from December 20, 2018

Angular 6 @Viewchild is not working with lazy loading

Image
7 1 Here is my code that gives error cannot read property title undefined. Parent Component import { Child } from './child.component'; @Component({ selector: 'parent', }) export class ParentComponet implements OnInit, AfterViewInit { constructor(){} @ViewChild(Child) child: Child; ngAfterViewInit(){ console.log("check data", this.child.title) } } And Child Component is. @Component({ selector: 'child', }) export class ChildComponet { public title = "hi" constructor(){} } routing.module.ts is like { path: "", component: ParentComponent, children: [ { path: '/child', component: ChildComponent } ...