I have a component that renders data based on the URL - '/lp/:pageId', :pageId is responsible for fetching data from the server called from ngOnInit().
ngOnInit(){
this.apiHelper.getData(this.route.snapshot.params.pageId);
}
I am facing an issue when ->
- I open
/lp/apple=> this fetches data related to apple and renders properly - But when I'm on
/lp/appleand press the link which navigates to/lp/banana=> only the route changes but does not fetch any data as the component is already loaded.
I tried calling the function to fetch data whenever the route changes, but that breaks some existing functionalities.
Any help regarding good Angular practice with this issue would be helpful. Thank you.