导航到另一条路线时如何保存数据?例如,我有以下路线。我导航到routerA并输入一些数据。如果我导航到routerB,然后再导航回routeA,则不会看到我输入的先前数据。
const appRoutes: Routes = [
{ path: 'routerA', component: RouterAComponent },
{ path: 'routerB', component: RouterBComponent }
]
答案 0 :(得分:0)
您应该使用service在变量中存储数据,并通过service访问该数据。
.....
@Injectable()
export class UserService {
public username;
MPIDList: any;
days: any;
uid: String;
BackUrl: any;
activeMPID: String;
LastExecutionDate: String;
....