【发布时间】:2016-06-25 09:00:29
【问题描述】:
这是我的 json:
{
"data": [
{
"comment": "3541",
"datetime": "2016-01-01"
}
]
}
这是型号:
export class Job {
constructor(comment:string, datetime:Date) {
this.comment = comment;
this.datetime = datetime;
}
comment:string;
datetime:Date;
}
查询:
getJobs() {
return this._http.get(jobsUrl)
.map((response:Response) => <Job[]>response.json().data)
}
问题是在转换为Job[] 之后,我希望datetimeproperty 是Date,但它是字符串。它不应该转换为 Date 对象吗?我在这里错过了什么?
【问题讨论】:
-
阅读那个,并没有真正回答我关于 TS 的问题
标签: json typescript angular