我正在尝试将包含日期和时间的变量绑定到Component A
. 我可以在控制台中看到 的值currentDate
,但是当我尝试将变量绑定到 时value
,key = currDate
我收到一条错误消息,指出该变量未定义。
本质上,我想undefined
用类似的东西替换它所说的部分Friday May 21 11:38:19
组件 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 ...