我的页面描述了学生的详细信息,此外我在我的页面上有组件,如与其他学生列表的组合,当我从列表中选择其他学生并点击它(这是我正在使用的链接href)我想要要显示的同一页面,但是我点击了学生的详细信息。
<a *ngIf="student?.studentId!=studentId" [routerLink]="['/studentDetailsContainer',student?.Branch,student?.studentId]"/>
这是我的组件代码:
@Component({
selector: 'studentDetails',
templateUrl: './app/student/student.details.html',
})
export class StudentDetailsComponent extends TooltipComponent implements OnInit {
public students: Student[];
public student: Student;
public studentId: number;
private sub: any;
private branch: number;
private AdditionsArr: Student[];
public AllStudents: Student[]
constructor(private studentDetailservice: StudentService, private route: ActivatedRoute, tooltipService: TooltipService) {
super(tooltipService);
}
getStudent() {
this.sub = this.route.params.subscribe(params => {
this.studentId = +params['studentId'];
this.branch = +params['branch'];
});
this.studentDetailservice.getStudent(this.branch, this.studentId).subscribe(data => {
this.students = data;
this.studentDetails = this.students[0];
this.AdditionsArr = this.studentDetails.AdditionsArr;
}, err => {
});
}
getStudents() {
this.studentDetailservice.getStudents().subscribe(data => {
this.AllStudents = data;
})
}
ngOnInit(): void {
this. getStudents();
this.getStudent();
}
}
应该为我选择的学生详细信息的函数是getStudent()。当我调试时,我只获得this.sub并填写params,之后我不回来从服务中获取详细信息....
我现在得到的结果是URL已更改,我的列表已更改(我链接的学生不在列表中。)但页面与之前的学生详细信息相同....我想我需要一些活动来重新加载我的页面...有人可以帮助我吗?谢谢。