0

How to save data when I navigate to another route? For example, I have routes as below. I navigate to routerA and input some data. If I navigate to routerB and then navigate back to routeA I won't see the previous data that I input.

const appRoutes: Routes = [
  { path: 'routerA', component: RouterAComponent },
  { path: 'routerB', component: RouterBComponent }
]
rebecca
  • 31
  • 3

1 Answers1

1

you should use service for store data in variable and access this data through service.

.....
    @Injectable()
    export class UserService {

      public username;
      MPIDList: any;
      days: any;
      uid: String;
      BackUrl: any;
      activeMPID: String;
      LastExecutionDate: String;

....
Nitin Wahale
  • 1,666
  • 2
  • 14
  • 25