我从RESTful服务中获得以下数据:
[
{
"id": 42,
"type": 0,
"name": "Piety was here",
"description": "Bacon is tasty, tofu not, ain't nobody like me, cause i'm hot...",
}...
我正在映射这个类:
export enum Type {
Info,
Warning,
Error,
Fatal,
}
export class Message{
public id: number;
public type: Type:
public name: string;
public description: string;
}
但当我在Angular2中访问"type"时,我只得到一个int值.但我想得到一个字符串值.
例如:
'message.type=0'
{{message.type}} => should be Info
'message.type=1'
{{message.type}} => should be Warning