I'm using Angular5 and i can't go back in the browser without losing data. I mean, that the previous component, could be loaded with their data again.
Example:
In my component:
import { Location } from '@angular/common';
@Component({
selector: 'app-mant-cert-certificacion',
templateUrl: './mant-cert-certificacion.component.html',
styles: []
})
export class MantCertCertificacionComponent implements OnInit {
constructor(private location: Location) {
}
goBack() {
this.location.back();
console.log( 'goBack()...' );
}
}
mant-cert-certificacion.component.html:
<a href="javascript:void(0)" (click)="goBack()">
<- Back
</a>
This component, it's called from my router module. When i click on the "go back" button, i wish to display the previous component with their data loaded.
My route module:
export const routes: Routes = [
{ path: 'xxxx', children: [
{ path: '', component: XComponent},
]},
{ path: 'yyyy', children: [
{ path: 'contractdetail/', component: MantCertCertificacionComponent}
]}
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class MantenedoresCertRoutingModule { }
Some idea?
This previous component would be "XComponent". The content of the information (attributes or variables) does not matter. I only want to load their data please.
Thanks!