import { Component, Input } from '@angular/core'; import { Term } from '../../core/models/term'; import { Course } from '../../core/models/course'; import { DataService } from '../../core/data.service'; @Component({ selector: 'app-term-container', templateUrl: './term-container.component.html', styleUrls: ['./term-container.component.scss'] }) export class TermContainerComponent { @Input() term: Term; terms: any[]; courses: Course[]; constructor(private dataService: DataService) { this.dataService.getDegreePlannerCourseData() .subscribe(degreePlanCourses => { this.terms = degreePlanCourses; }); } getCoursesByTerm( termCode ) { if (this.terms) { for ( const term of this.terms ) { if (term.termCode === termCode) { return term.courses; } } } return []; } }