import {Component, OnDestroy, OnInit} from '@angular/core'; import {LecturerInfoService} from '../../services/lecturer-info.service'; import {LecturerDataService} from '../../services/lecturer-data.service'; import {Router} from '@angular/router'; import {MinutePaperDao} from '../../dao/minute-paper.dao'; @Component({ selector: 'app-lecturer-paperview', templateUrl: './lecturer-paper-view.component.html', styleUrls: ['./lecturer-paper-view.component.css'] }) export class LecturerPaperViewComponent implements OnInit, OnDestroy { public classCode: String; public lecturerId: String; public classPapers: MinutePaperDao[]; constructor(private lecturerInfoService: LecturerInfoService, private lecturerDataService: LecturerDataService, private router: Router) { } ngOnInit(): void { this.classPapers = []; this.classCode = this.lecturerDataService.classCode; this.lecturerId = this.lecturerDataService.lecturerId; this.getClassesPapers(); } ngOnDestroy(): void { this.classPapers = []; } public goToSubmissionsView(paper) { this.classPapers = []; this.lecturerDataService.currentPaper = paper; this.router.navigate(['/submissionsview']); } private getClassesPapers(): void { this.lecturerInfoService.getClassPapers(this.lecturerId, this.classCode).subscribe((data: MinutePaperDao[]) => { data.forEach(p => {this.classPapers.push(p); }); }); } }