Sujeet Raman

Sujeet Raman

  • 868
  • 927
  • 358.1k

Routparameter is expiring while switching to next component

Dec 19 2017 8:41 AM
Hi, in my roting app am using childroots.based on one id i need to bind 2 diffrent component ie:Student,Teacher
problem
1. in UI am getting 2 tabs
Students Teacher
student is loading according to id but if i switch teacher i lost the details of student id showing undefined
2.how can i use same param(here id) getteachers() in teacher component same as student
i am getting id from details component click event
event(){
this.Router.navigate(['Main/student',Id])
}
in student component.ts
this.subscription = this.Route
.params
.subscribe(params => {
this.Id = +params['MMId'];
this.getdetails(this.Id)
});
: i have created child roots(containing parameter route) and parent roots
path: 'Main',
component: Main,
children: [
{ path: 'student/:Id', component: studentComponent },
{
path: 'Teacher', component: TeacherComponent,}