I am currently facing a challenge with my components B and A. Component B has a post method that inserts new data and navigates directly to component A, which has a get method to display the inserted data.
My issue is how to retrieve the new data without refreshing the page. I have managed to make it work by placing navigation end in both ngOnInit and constructor.
constructor(private auth: FirstAksamProspectService, private router: Router) {
this.router.events.subscribe((router) => {
if (router instanceof NavigationEnd) {
this.getlistAffectaion_employe();
}
});
}
ngOnInit(): void {
this.router.events.subscribe((router) => {
if (router instanceof NavigationEnd) {
this.getlistAffectaion_employe();
}
});
this.getlistAffectaion_employe();
}
Is there an alternative way to achieve this?
Thank you for any assistance provided.