I have a problem while refreshing my page
I have a service that runs the following code:
service.ts
public goToCommit(value: boolean) {
if (this.accountServ.isAutho() || this.person.getNb() % 48 === 0) {
this.personService.savePerson(this.person).subscribe(() => {
this.person= null;
});
} else {
throw new Error('Account not authorized to goToCommit');
}
}
(this treatment is long, this method is used in other places )
in my component I have this:
component.ts
this.service.goToCommit(value);
this.router.navigate (['/persons']);
The problem is that I am redirected to /persons
before the processing ends.
How can I wait for the goToCommit
method to finish and redirect after ?
Thank you