串我從一個RESTful服務得到以下數據:演員INT以枚舉在打字稿
[
{
"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中,我只獲得一個int值。但我想獲得一個字符串值。
e.g:
'message.type=0'
{{message.type}} => should be Info
'message.type=1'
{{message.type}} => should be Warning
這是編譯時問題還是運行時問題? –
它編譯並運行良好。對於'{{message.type}]'我得到'0',但我想要'Info'。 –