I am trying to bind a variable which contains the date and time to a key value pair within Component A
. I can see in the console the value of currentDate
, but when I try to bind the variable to the value
of key = currDate
I get an error message stating that the variable is undefined.
Essentially, I would want to replace the part where it says undefined
with something like Friday May 21 11:38:19
Component A - ComponentA.ts
import { Component, HostListener } from '@angular/core';
import { service } from '../../..common/service';
... Some Code...
@Component({
selector: 'ComponentA',
styleUrls: ['./ComponentA.css'],
templateUrl: './ComponentA.html'
})
export class ComponentA {
... Some Code ...
currentDate: any;
plotDesc: { [key:string]: string } = {
currDate: `The number of open requests since <div *ngIf="currentDate">${this.currentDate.data.date}</div>`
};
constructor(private sw: Service){ }
... Rest of Code ...