title: Angular 5 convert Enum int to string
body: <p>I would like to display my enum as a string but it display as a number.</p>
  
  <p>I am receiving a json object from a web service and mapping it to my typescript object</p>
  
  <pre><code>getProperties(): Observable&lt;Property[]&gt; {
      return this.http.get&lt;Property[]&gt;(this.getallagentsproperties + '1');
  }
  
  export enum LetType {
      Notspecified = 0,
      LongTerm = 1,
      ShortTerm = 2,
      Commercial = 4
  }
  
  export class Property {
      ...other stuff...
      letType: LetType;
      ...other stuff...
  }
  </code></pre>
  
  <p>My component makes the call and adds it to the relevant property</p>
  
  <pre><code>import { Component, OnInit } from '@angular/core';
  import { Property } from './Property';
  import { PropertyService } from '../properties.service';
  
  @Component({
    selector: 'app-properties',
    templateUrl: './properties.component.html',
  })
  
  export class PropertiesComponent implements OnInit {
    properties: Property[];
    constructor(private propertyService: PropertyService) { }
    ngOnInit() {
      this.getProperties()
    }
    getProperties(): void {
      this.propertyService.getProperties()
          .subscribe(p =&gt; this.properties = p);
    }
  }
  </code></pre>
  
  <p>When I display <code>{{property.letType}}</code> in my template is displays:</p>
  
  <p><code>4</code> I want it to display Commercial</p>
  
  <p>I have tried to follow the answer found <a href="https://stackoverflow.com/questions/42299257/cast-int-to-enum-strings-in-typescript#_=_">here</a> in my template I added</p>
  
  <pre><code>{{LetType[property.letType]}}
  </code></pre>
  
  <p>and in my Componant I added</p>
  
  <pre><code>LetType = this.LetType;
  </code></pre>
  
  <p>but I always get the below error in the console</p>
  
  <blockquote>
    <p>Cannot read property '4' of undefined</p>
  </blockquote>
  
  <p>What am I doing wrong?</p>