After clicking a button that calls the add function below, the data is being added into the database but not on the frontend itself. How do you add it without loading the page?
addSection(section: Section) {
section.name = section.name.trim();
if(section.name != ''){
this.onToggleDialogBox();
this.sectionService
.registerSection(section)
.subscribe(
res => alert(res.message),
error => console.log(error)
)
}else{
alert('Enter name.');
}
}
If I use Router, here are the necessary codes:
constructor(
private router: Router,
private route: ActivatedRoute,
private sectionService: SectionService
) {}
this.router.navigate(['/information/sections']);
Try the subscription
of rxjs. After executing the method in service, append .finally
. In your component, subscribe to that method with the subscription. So that if that method is executed, it will reflect on the component without loading the page