title: Requesting Example for angular.js $http (not $resource) and ASP.NET/C#
body: <p>I'm still trying to learn how AngularJS's framework works, so please bear with me. </p>
  
  <p>I'm having issues in saving the data with BarcodeSave() method, however, I have no problem retrieving the data from BarcodeItem() and BarcodeList().</p>
  
  <p>What I've heard so far (I could be wrong), $resource is a bit limited for this project, which is why I'm only interested in using $http. Although, I like to hear your opinions with solutions regardless. </p>
  
  <p><strong>ASP.NET/C#</strong></p>
  
  <pre><code>public CsBarcode BarcodeSave(string barcodeVal, string courierType, string userName)
  Saves to the database and returns JSON, IsSuccess = true for success or IsFailed = true if failed. The status will be in the Status field
  Name: BarcodeSave
  Returns: CsBarcode (JSON object)
  Parameters
  barcodeVal (string) – the value that came from the scanner
  courierType (string) – the location, send constant: PICKUP or DROPOFF
  userName (string) – the login name of the user. Will come from the Sign In page
  
  
  public CsBarcode BarcodeItem(string barcodeVal, string userName)
  Retrieves information from the database for one individual item matching by the barcode value
  Name: BarcodeItem
  Returns: CsBarcode (JSON object)
  Parameters
  barcodeVal (string) – the value that came from the scanner
  userName (string) – the login name of the user. Will come from the Sign In page
  
  public List&lt;CsBarcode&gt; BarcodeList(string userName)
  Retrieves information from the database for all items by the courier - userName
  Name: BarcodeList
  Returns: List of CsBarcode (list of JSON objects)
  Parameters
  userName (string) – the login name of the user. Will come from the Sign In page
  </code></pre>
  
  <p><strong>AngularJS - Factory</strong></p>
  
  <pre><code>//Factory to get Pick Up List
  angular.module('app.pickUpServ', []).factory('pickUpServ', ['$http',
      function($http) {
  
      var params = "{'barcodeVal':'" + '12345678' +
              "','courierType':'" + 'PICKUP' +
              "','userName':'" + 'aspuser' + "'}";
  
          return {
              getPickUpList: function(data) {
                  $http({
                      method: 'POST',
                      url: 'app/Service/CourierService.asmx/BarcodeItem2',
                      data: params,
                      contentType: 'application/json; charset=utf-8',
                      dataType: 'json',
                  }).success(data).error(function (error) {
                      console.log('Error - getPickUpList');
                  });
              },
              updatePickUpList: function(data) {
                  $http({
                      method: 'POST',
                      url: 'app/Service/CourierService.asmx/BarcodeSave2',
                      contentType: 'application/json; charset=utf-8',
                      data: params,
                      dataType: 'json'
                  }).success(data).error(function (error) {
                      console.log('Error - updatePickUpList');
                  });
              }
          }
      }
  ]);
  </code></pre>
  
  <p><strong>AngularJS - Controller</strong></p>
  
  <pre><code>angular.module('app.scanListCtrl', []).controller('ScanListCtrl', ['$scope', '$rootScope', 'pickUpServ', function ($scope, $rootScope, pickUpServ) {
          //Get Pick Up Data
          pickUpServ.getPickUpList(function (data) {
                  $scope.items = data;
                  console.log(data);
          });
  
  } ]);
  </code></pre>
  
  <p><strong>JSON</strong></p>
  
  <pre><code>[
    {
         "Id":1,
         "BarcodeValue":"99999999",
         "CSN":"99999999",
         "MRN":"99999999xxx",
         "UserName":"steinan",
  "FirstName":"Anthony",
  "LastName":"Stein",
  "DateProcessed":"9/1/2014",
  "IsProcessed":false,
  "IsSuccess”:false,
  "IsFailed":true,
         "Status":"Failed"
    },
    {    "Id":1,
         "BarcodeValue":"88888888",
         "CSN":"88888888",
         "MRN":"88888888xxx",
         "UserName":"davisnick",
  "FirstName":"Nick",
  "LastName":"Davis",
  "DateProcessed":"8/1/2014",
  "IsProcessed":true,
  "IsSuccess”:true,
  "IsFailed":false,
         "Status":"Success"
    }
  ]
  </code></pre>
  
  <p><strong>HTML</strong></p>
  
  <pre><code>&lt;div ng-controller="ScanListCtrl"&gt;
      &lt;div class="row prepend-top-md"&gt;
          &lt;div class="col-lg-12"&gt;
              &lt;div class="panel panel-default"&gt;
                  &lt;div class="panel-heading"&gt;
                      &lt;h3 class="panel-title"&gt;
                          &lt;i class="fa fa-barcode"&gt;&lt;/i&gt;&amp;nbspScan Item&lt;/h3&gt;
                  &lt;/div&gt;
                  &lt;div class="panel-body"&gt;
                      &lt;div class="input-group input-group-lg"&gt;
                          &lt;input type="number" class="form-control" placeholder="Scan Item" ng-model="BarcodeValue"
                              ng-change="autoAddItem()" is-focus&gt;
                          &lt;span class="input-group-btn"&gt;
                              &lt;button class="btn btn-info" type="button" ng-click="addRow()"&gt;
                                  Add Barcode&lt;/button&gt;
                          &lt;/span&gt;&lt;/div&gt;
                  &lt;/div&gt;
                  &lt;table class="table table-striped table-hover"&gt;
                      &lt;thead&gt;
                          &lt;tr&gt;
                              &lt;th class="text-center" style="width: 3%"&gt;
                                  #
                              &lt;/th&gt;
                              &lt;th&gt;
                                  &lt;i class="fa fa-barcode"&gt;&lt;/i&gt;&amp;nbspBarcode
                              &lt;/th&gt;
                              &lt;th&gt;
                                  &lt;i class="fa fa-medkit"&gt;&lt;/i&gt;&amp;nbspCSN
                              &lt;/th&gt;
                              &lt;th&gt;
                                  &lt;i class="fa fa-user"&gt;&lt;/i&gt;&amp;nbspUser
                              &lt;/th&gt;
                              &lt;th&gt;
                                  &lt;i class="fa fa-clock-o"&gt;&lt;/i&gt;&amp;nbspDate
                              &lt;/th&gt;
                          &lt;/tr&gt;
                      &lt;/thead&gt;
                      &lt;tbody&gt;
                          &lt;tr ng-repeat="item in items | orderBy:'Id':true:reverse"&gt;
                              &lt;td class="text-center"&gt;
                                  [{{item.Id}}]
                              &lt;/td&gt;
                              &lt;td&gt;
                                  {{item.BarcodeValue}}
                              &lt;/td&gt;
                              &lt;td&gt;
                                  {{item.CSN}}
                              &lt;/td&gt;
                              &lt;td&gt;
                                  {{item.LastName + ', ' + item.FirstName}}
                              &lt;/td&gt;
                              &lt;td&gt;
                                  {{item.DateProcessed}}
                              &lt;/td&gt;
                          &lt;/tr&gt;
                      &lt;/tbody&gt;
                  &lt;/table&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>