我正在尝试发送对象参数。来自列表组件。
editStudent(student)
{
this.router.navigate(['/addStudent', student]);
}
studentModel对象类似于:
addressModel = new AddressClass("", "", "");
studentModel = new StudentClass(0,"", "", "", "", "", true, "", this.addressModel)
我正在尝试在其他组件上读取学生对象:
ngOnInit() {
this.studentModel = this.route.snapshot.paramMap.get('stud');
}
答案 0 :(得分:0)
方法是:-
editStudent(student)
{
this.router.navigate(['/addStudent', {'data' : JSON.stringify(student)}]);
}
ngOnInit() {
this.studentModel = JSON.parse(this.route.snapshot.paramMap.get('data'));
}