Here is my json:
{
"data": [
{
"comment": "3541",
"datetime": "2016-01-01"
}
]
}
Here is model:
export class Job {
constructor(comment:string, datetime:Date) {
this.comment = comment;
this.datetime = datetime;
}
comment:string;
datetime:Date;
}
Query:
getJobs() {
return this._http.get(jobsUrl)
.map((response:Response) => <Job[]>response.json().data)
}
Problem is that after casting to Job[]
i expect datetime
property to be Date
but it is string. Shouldn't it cast to Date object? What am i missing here?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…