Skip to content

Commit

Permalink
The DayGridComponent updates as navigation occurs
Browse files Browse the repository at this point in the history
Implemented the `DoCheck` interface instead of `OnInit`. This allowed the component to detect that changes occurred and update itself from the latest `CalendarService` state.

ref issue #5
  • Loading branch information
Eric McIntyre committed Nov 7, 2016
1 parent e8fabda commit b7df5e9
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/app/day-grid/day-grid.component.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import {Component, OnInit} from '@angular/core';
import {Component, OnInit, DoCheck} from '@angular/core';
import {CalendarService} from '../calendar.service';

@Component({
selector: 'cal-day-grid',
templateUrl: './day-grid.component.html',
styleUrls: ['./day-grid.component.css']
})
export class DayGridComponent implements OnInit {
export class DayGridComponent implements DoCheck {
daysOfWeek: string[];
daysOfMonth: number[][];

constructor(private calendarService: CalendarService) {
}

ngOnInit() {
ngDoCheck() {
this.daysOfWeek = this.calendarService.daysOfWeek;
this.daysOfMonth = this.calendarService.daysOfMonth;
}
Expand Down

0 comments on commit b7df5e9

Please sign in to comment.