When a user attempts to update a student, I pass in the student ID. The update successfully redirects to the updateStudent page and displays the student ID in the browser link. However, within my app component, it shows as undefined.
Student View component sending sid to update Student component:
updateStudent(id: number) {
console.log(id);
this.router.navigate(['/updateStudent', id]);
}
Update Student component:
export class UpdateStudentComponent implements OnInit {
id: number;
constructor( private route: ActivatedRoute,private router: Router{
this.id = this.route.snapshot.params['id'];
console.log(this.id);
}
}
Routing Module:
const routes: Routes = [
path: 'studentsList', component: StudentsListComponent },
path: 'updateStudent/: id', component: UpdateStudentComponent },
path: ' ', redirectTo: 'main', pathMatch: 'full' },
];