title: How to post data on button click using AngularJS
body: <p>I have an application made with .NET core framework and pure html in the front end. I was using AJAX to post and get data. 
  I am new to Angular and decided to convert the front end of the application to Angular for learning purposes.</p>
  
  <p>For Example, I have a button that will change the state of employees from 'Billed' to 'Available' state. The ID for available state is defined in the back end and it is '1'.</p>
  
  <pre><code>     //MOVE TO BENCH BUTTON CLICK
  
          $(document).ready(function()
          {
              var allVals = [];
  
  
              $("#MoveToBench").click(function()
              {
                  $('input:checkbox:checked').each(function () {
                      allVals.push($(this).val());
                  });
                  for (i = 0;i&lt;allVals.length;i++){
                      PostBenchList(allVals[i])
                  }
                  function PostBenchList(entityId) {
                      var data = 'entityID='.concat(entityId).concat('&amp;nextStateId=1');
  
                      $.ajax({
                          type: "POST",
                          contentType: "application/json; charset=utf-8",
                          url: "http://localhost:1783/api/Workflow?"+data,
                          data: data,
                          dataType: "text",
                          success: function (data) {
                              location.reload();
                              alert("Successfully added the selected Employees to TalentPool");
                          },
                          fail: function (error) {
                              Console.Log(error);
                          }
                      })
                  }
              });
  
          });
  </code></pre>
  
  <p>The above code is taking an array of entityID's as input. For the Angular application, the array is not required as only one entity ID will be passed. </p>
  
  <p>The API controller in the backend is :</p>
  
  <pre><code> // POST api/values
          [HttpPost]
          public void Post(int entityId, int nextStateId)
          {
              JObject jsonObject = JObject.Parse(System.IO.File.ReadAllText("Config.Json"));
              string jsonFile = jsonObject.GetValue("WorkfowJsonFileLocation").ToString();
              var nextState = _stateServices.Get(nextStateId);
              var handler = new WorkflowHandler(nextState, jsonFile, _entityServices, 1, _stateServices, _subStateServices, _appServices);
              handler.PerformAction(entityId);
          }
  </code></pre>
  
  <hr>
  
  <p>The above code worked for me and it would change the state ID of the employee(EntityID)to 1(nextStateId)</p>
  
  <p>Now I have a button in AngularJS and I want it to do the same action. How would I achieve this? As I am still in the procedure of learning, I don't have a clue how to do this. Can anyone help me to achieve this? This would help me to learn and do all similar buttons.</p>
  
  <p>Thank You.</p>