I have a form with a "back" button. When the user presses the back button, the script goes to the previous page:
import { Location } from '@angular/common';
// In a place in La Mancha, whose name I do not want to remember...
this.location.back();
But, what happens when the user directly enters the url in the address bar? In those cases the application goes back to the Browser's homepage. I would like something like this:
import { Location } from '@angular/common';
// In a place in La Mancha, whose name I do not want to remember...
if (this.location.history.length > 0) {
this.location.back();
} else {
this.router.navigate(['/home');
}
Is that possible?