Despite not receiving any errors from Visual Studio Code, I’m encountering an error in Chrome's console.
Below is the code snippet from my interfaces.ts file:
export interface Data1{
month: string;
employeeName: string;
date: string;
employmentStatus: string[];
}
And here's the code snippet from tables.component.ts:
import { Component, OnInit } from '@angular/core';
import { Data1 } from '../../../shared/interfaces';
@Component({
selector: 'app-tables',
templateUrl: './tables.component.html',
styleUrls: ['./tables.component.css']
})
export class TablesComponent implements OnInit {
today = new Date();
dataForTable1: Data1;
months: string[] = [
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December"
]
constructor() {
console.log(this.today.getMonth());
console.log(this.months[this.today.getMonth()]);
this.dataForTable1.month = this.months[this.today.getMonth()]
this.dataForTable1.employeeName = '';
this.dataForTable1.date = this.today.getDate().toLocaleString();
this.dataForTable1.employmentStatus = [''];
}
ngOnInit() {
}
}
After using console.log for debugging, the correct outputs are displayed but it still shows as undefined. I am currently working with Angular CLI version 1.7.4; Node version 8.11.1; Typescript version 2.8.1. Any assistance would be greatly appreciated.