我从一个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”时,我只得到一个整数值。但我想得到一个字符串值。
例如:
'message.type=0'
{{message.type}} => should be Info
'message.type=1'
{{message.type}} => should be Warning
{{message.type}}
,我得到了0
,但我想要得到Info
。 - Franz Peter Tebartz van Elst