title: How to send enum value to API using Angular 5?
body: <p>Hi I am working on web application developed on Angular 5. I am sending data back to API. API model is as below.</p>
  <pre><code>public partial class ResourceDTO
         {
          [JsonProperty(&quot;id&quot;)]
          public System.Guid Id { get; set; }
  
          [JsonProperty(&quot;state&quot;)]
          public State State { get; set; }
         }
  public enum State 
  {
        NotSelected = 0,
        Allowed = 1,
        Denied = 2
  }
  </code></pre>
  <p>I want to send data to the API. Below is my enum defined in type script.</p>
  <pre><code>export enum State {
      NotSelected,
      Allowed,
      Denied 
  }
  </code></pre>
  <p>In below function I am consolidating my data.</p>
  <pre><code> data.forEach(element =&gt; {
              const object = { modelType: '', userroleid: '', name: [], hasChildren: false, id: '', state: State };
             
              if (element.id != undefined) {
                  object.id = element.id;
              }
              if (element.checked == false) {
                  object.state.NotSelected;
              }
              if (element.checked == true) {
                  object.state.Allowed;
              }
              if (element.allow == false) {
                  object.state.Denied;
              }
              saveData.push(object);
          }); 
  </code></pre>
  <p>Below is the saveData after consolidating the data.</p>
  <p><a href="https://i.stack.imgur.com/CUqaT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CUqaT.png" alt="enter image description here" /></a></p>
  <p>Can someone tell me Am I doing it correctly or something I am missing? Above output is expected one? Any help would be appreciated. Thank you.</p>