I am loading some backend api data on homepage in ngOnInit()
export class MyComponent{
homepagedata:any; // displayed on the html
ngOnInit() {
this.homepagedata=// calling service
}
}
This is my routes
{
path: 'home',
component: HomeComponent,
children: [
{
path: 'dashboard/:userid', //
component: DashboardComponent,
},
]
}
So when I navigate to dashboard ,and then navigate again to home ,my home component doesn't gets refreshed ,may be because ngOnInit() is called once .How to call this ngOnit() every time I navigate to home.I tried with ngAfterViewInit() but its also only called once.
I found a similar problem here.But here it is navigating after the function call ,which is not in my case .There are many child components in my case ,and I am looking for one solution that can fit all.Thanks