में तार Enum के लिए मैं एक 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 में मुझे केवल एक int मान मिलता है। लेकिन मैं एक स्ट्रिंग मान प्राप्त करना चाहता हूं।
उदाहरण के लिए:
टाइपप्रति में'message.type=0'
{{message.type}} => should be Info
'message.type=1'
{{message.type}} => should be Warning
क्या यह संकलन-समय समस्या या रनटाइम समस्या है? –
यह संकलित करता है और ठीक चलाता है। '{{Message.type}] के लिए 'मुझे' 0' मिलता है लेकिन मैं' जानकारी 'प्राप्त करना चाहता हूं। –