From b7df5e9aeb5474490452349fe7d874a873b72093 Mon Sep 17 00:00:00 2001 From: Eric McIntyre Date: Mon, 7 Nov 2016 16:39:05 -0700 Subject: [PATCH] The `DayGridComponent` updates as navigation occurs 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 --- src/app/day-grid/day-grid.component.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/app/day-grid/day-grid.component.ts b/src/app/day-grid/day-grid.component.ts index bbf913f..b34c795 100644 --- a/src/app/day-grid/day-grid.component.ts +++ b/src/app/day-grid/day-grid.component.ts @@ -1,4 +1,4 @@ -import {Component, OnInit} from '@angular/core'; +import {Component, OnInit, DoCheck} from '@angular/core'; import {CalendarService} from '../calendar.service'; @Component({ @@ -6,14 +6,14 @@ import {CalendarService} from '../calendar.service'; 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; }