import { Component, OnInit } from '@angular/core'; import { Location } from '@angular/common'; import { DemoService } from '../services/demo.service'; @Component({ selector: 'app-attendance', templateUrl: './attendance.component.html', styleUrls: ['./attendance.component.scss'] }) export class AttendanceComponent implements OnInit { selectedList: number = 1; selectedSegment: any; selectedSegmentTab: any; selectedReportYear: any; demoType: string; attendanceList = []; constructor( private location: Location, private demoService: DemoService ) { } ngOnInit(): void { this.demoType = localStorage.demoType; this.attendanceList = this.demoService.attendanceList; if (this.demoType === 'Teacher') { this.selectedList = 1; this.selectedSegment = this.attendanceList[0]; this.selectedSegmentTab = this.attendanceList[0].subjects[0]; this.selectedReportYear = this.attendanceList[0].subjects[0].attendance[0].year; } else { this.selectedList = 1; this.selectedSegment = 'ALL'; this.selectedSegmentTab = 'report'; this.selectedReportYear = 2020; } } back() { this.location.back(); } }